There are multiple ways to do so. In the following, I will list some approaches (there will be a suggestion at the end if you cannot decide for an approach):
Types of differences
There are 3 main types of differences I would like to start with:
- Direct difference between the images (e.g. mean squared difference between pixels, as you mentioned)
- Difference between the histogram
- Difference between contrast measures.
The problem with approach 1 is, that there can be two images with the same difference to the original image, but one has increased, the other one decreased constrast. Just imagine to darken dark pixels and brighten bright pixels in one image (this increases the contrast) and on the other hand brighten dark pixels and darken bright pixels (this decreases contrast). Both will have the same (absolute / square) difference to the original image.
Approach 2 gives you a global view on images. The question is how to measure the difference of histograms (see below.) The problem is, that a different histogram does not necessarily mean that the constrast is different. Image a dark image with gray values between 0 and 127 (on a scale from 0 to 255). If you light up the image, the (now it has values 128 to 255), the contrast does not change, just the brightness.
Approach 3 allows to directly compare contrasts. It has the potential to take into account local distribution of pixels (yet, I will focus in the following on global contrast definitions). The key is how to measure contrast.
Difference between histograms
There are different ways to compare histograms / distributions:
- One could compute the bin-wise differences,
- There is the Kullback-Leibler-Divergence
- Another way is the earth-mover- / Wasserstein-distance.
While the former two do not measure well by how much pixels are darkened / brightened, the earth-mover distance does exactly this.
Imagine a binary image with pixels of gray value 0 or 1 (on the scale up to 255). One method to increase contrast lead to an image with values 0 and 5, another method produces values 0 and 255. Of the three mentioned methods, only Wasserstein detects that the second method creates a larger improvement.
Suggestion: Use Wasserstein Distance to compare histograms with respect to contrast.
How to measure contrast of an image.
There exist difference ways to measure the contrast of an image, e.g.
- The Michelson Contrast $$\frac{I_{max}-I_{min}}{I_{max}+I_{min}}$$ only consideres the darkest and brightest values.
- The RMS contrast measures the standard deviation of the gray values in the image: $$\sqrt{\frac{1}{NM}\sum_{i=1}^M\sum_{j=1}^N(I_{ij}-\bar{I})^2}$$ with then $I_{ij}$ being a single pixels value and $\bar{I}$ being the average gray value of the image. This takes into account all pixels of the image.
Suggestion
I would start with the RMS Contrast, but it depends a bit what exactly you are interested in.
Outlook
All discussed approaches are dealing with the global contrast. There are adaptive / local methods that act differently, depending on the surrounding of a pixel. Image an image that has bright and dark areas. A slightly dark pixel might be brightened in dark areas whereas a slightly dark pixel might be darkened in bright areas to increase contrast.
To measure the contrast in such situations, one needs a contrast measure that takes into account the local contrast. RMS contrast over small areas might be a start for that.