问题
Suppose I have images as follows:
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.
回答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.
Additional notes on the method are in image comparison algorithm part Optimization 2.
来源:https://stackoverflow.com/questions/62704531/finding-similar-images-with-different-intensities-brightness