'Finding similar images with different intensities/brightness

Suppose I have images as follows:

enter image description here

enter image description here

What would be my options to compare the similarity between the two images? Obviously they are the same image just with different brightness. I couldn't find any plausible way for this and currently my best bet would be to train a cnn or autoencoder and compare the feature vectors of the outputs, but that just seems a bit overkill for this. Any tips would be appreciated.



Solution 1:[1]

Pretty robust working solution (I tested) is to check correlation of brightness sign changes between pixels.

I.e. assuming images A and B, loop for significant number of pixels:

IF (
  (brightness of pixel 1 from A IS LARGER than brightness of pixel 2 from A)
  AND
  (brightness of pixel 1 from B IS LARGER than brightness of pixel 2 from B)
) {
  COUNTER++;
}

And vice versa for opposite relationship. The higher the COUNTER the more similar are the images.

IMPORTANT: I tested the method on (inter-area) scaled-down images, not full size, as full size images may contain some compression artifacts. My intuition suggests it will work on full size images anyway, just with a different threshold. If not, resize by area to preserve well average brightness values (similar to INTER_AREA in OpenCV), and it will do the trick.

Related ideas can be found at image comparison algorithm.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1