1

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.

Image 1

Image 2

Contour_1_2

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)

Image 1 Adjusted

Image 2 Adjusted

However, the result is still showing differences in the images.

Filled_1_2_adjusted

Contour_1_3_adjusted

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.

Bilal
  • 3,191
  • 4
  • 21
  • 49
Anh Phan
  • 15
  • 7
  • 1
    Normalize the images by subtracting their mean and then dividing that by their standard deviation – fmw42 Jul 10 '23 at 16:02
  • 1
    Or use that equation to change one image to match the other. See https://pyimagesearch.com/2014/06/30/super-fast-color-transfer-images/ – fmw42 Jul 10 '23 at 17:32

0 Answers0