Loss function for 2d output

my output is a 2d matrix I’d like to use a loss function that takes into consideration the spatial component of the output signal, if anyone has any suggestions I would greatly appreciate it.

Ssim in image quality evaluation can be a way to be tried