This is a great question and something I have wrestled with quite a bit! The pursuit of pattern similarity metrics leads down a rabbit hole to entire fields of statistical, spatial, and even fractal methods of analyzing patterns. Each of these methods has applications in geoscience and geospatial analysis, but none offer complete measures of pattern similarity. With a little imagination we can construct spatial patterns which have identical means, standard deviations, and probability distributions, but which entirely lack similar structures, or any recognizable structures at all. For example, the patterns below are quite similar statistically in some cases - yet are not similar at all to our human eyes.
We can increase complexity and try spatial metrics (e.g. semivariance, global autocorrelation) but they may also struggle to separate two well organized patterns that are otherwise divergent. Fractal measures of dimension and roughness may tell us something about similarity and scale - but can be difficult to implement and interpret.
We need a more robust pattern analyzing machine, and fortunately Nature has produced such a machine for us to use already: the human visual system. Humans are adept at recognizing and comparing visual patterns. The similarity analysis methods I've been working with derive from research on how the human visual system recognizes the similarity of two patterns. I've been experimenting with 5 methods:
Mean Square Error (MSE) (this is the method suggested by @Spacedman)
MSE is a familiar, easy to implement, and easy to interpret metric
of pattern similarity. However, it can be a poor measure of
perceptual similarity because it is sensitive to geometric
distortions. We can fool MSE: take two images, a reference image and
a target image. They are almost identical, but the target image has
been geometrically translated by a small amount. Such a registration
shift will cause high MSE values indicating poor similarity, but a
human observer would see little difference in the information
content of the images because humans automatically do the
translation.
Structural Similarity Index Method (SSIM) SSIM measures the local similarity of three elements: luminance (brightness values), contrast, and structure. These similarities are combined to form SSIM values. SSIM scores range from -1 to +1, with the latter score indicating that the reference and target patterns are identical. While the SSIM index is more nuanced than MSE because it contains perceptually important information like contrast and structure, it is still flawed because it is also sensitive to geometric translations, scalings, and rotations.
Complex Wavelet SSIM (CW-SSIM) The drawbacks of SSIM bring us to a wavelet-domain version of SSIM. The complex wavelet implementation compares sets of coefficients extracted at the same spatial location in the same wavelet subbands of two images. The consistency of phase changes between the coefficients measures how consistent structural information is between the two images. CW-SSIM is robust to translations and small scaling and rotational differences. Note that results can depend on the parameters of the wavelet. Wang and Bovik (2009) provide an excellent summary of MSE, SSIM, and CW-SSIM.
Gradient Magnitude Similarity Deviation (GMSD) GMSD is included in this analysis because it outperforms a variety of SSIM implementations for many test databases and is computationally more efficient. In this implementation, image gradient maps are computed in the x and y directions using a 3x3 Prewitt filter. A gradient magnitude similarity (GMS) map combines the gradients of the reference and target images, and the standard deviation of the GMS map is computed as the overall measure of pattern similarity. A lower GMSD value indicates higher quality and less distortion (i.e., less difference) in the two structures (Xue et al., 2014).
Feature Similarity (FSIM) FSIM is a high performing but computationally expensive method. Phase congruency and gradient magnitude images are created for the reference and target images. The similarities between these products are computed and combined, and then weighted using maximum phase congruency to produce the FSIM score. Higher FSIM values indicate better similarity (Zhang et al., 2011).