I am trying to compare two images and detect the difference between them whether in shape or color.
-The change in shape: the number of parts has changed ( increased or decreased). -The change in color: some of the parts were in pink and changed into white and vice versa.
I have tried 3 algorithms:
- Compare by Compare_ssim.
- Difference detection by PIL (ImageChops.difference).
- Images subtraction.
The first algorithm:
(score, diff) = compare_ssim(img1, img2, full=True) diff = (diff * 255).astype("uint8")
The second algorithm:
from PIL import Image ,ImageChops img1=Image.open("canny1.jpg") img2=Image.open("canny2.jpg") diff=ImageChops.difference(img1,img2) if diff.getbbox(): diff.show()
The third algorithm:
The problem is these algorithms are so sensitive. If the images have different noises and different angle of capture, they consider that the two images are totally different. Any ideas to fix that?