I am making a program that compares and points out the differences between the two images using the skimage
library.
def get_structural_simlarity(first_image, second_image):
print("[Console] Calculating differences")
# Pre-process Image
first_gray = convert_to_gray(first_image)
second_gray = convert_to_gray(second_image)
# Compare
(score, diff_img) = structural_similarity(first_gray, second_gray, full=True)
# Convert return format to cv2 readable
diff_img = convert_to_cv2_format(diff_img)
print("[Console] Similarity score of {:.4f}%".format(score * 100))
return diff_img
It works how I wanted it to when comparing two different images. However, the problem is when I compare Image 1
with Image 2
, where Image 2
is Image 1
with contrast and brightness adjusted. What I intended to do is for the program to point out there are no differences. However, the contrast and brightness difference changed the result.
So far, I have tried using the skimage.exposure.equalize_adapthist
method to adjust the contrast for all input images.
equalize_adapthist(image, kernel_size=None, clip_limit=0.01, nbins=256)
However, the result is still showing differences in the images.
I need help finding a way to readjust and match the brightness and contrast, or even color between the input images to point out more accurate differences.