Image comparison algorithm

前端 未结 9 1636
礼貌的吻别
礼貌的吻别 2020-11-28 00:48

I\'m trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite go

9条回答
  •  无人及你
    2020-11-28 01:19

    You really need to specify the question better, but, looking at those 5 images, the organisms all seem to be oriented the same way. If this is always the case, you can try doing a normalized cross-correlation between the two images and taking the peak value as your degree of similarity. I don't know of a normalized cross-correlation function in Python, but there is a similar fftconvolve() function and you can do the circular cross-correlation yourself:

    a = asarray(Image.open('c603225337.jpg').convert('L'))
    b = asarray(Image.open('9b78f22f42.jpg').convert('L'))
    f1 = rfftn(a)
    f2 = rfftn(b)
    g =  f1 * f2
    c = irfftn(g)
    

    This won't work as written since the images are different sizes, and the output isn't weighted or normalized at all.

    The location of the peak value of the output indicates the offset between the two images, and the magnitude of the peak indicates the similarity. There should be a way to weight/normalize it so that you can tell the difference between a good match and a poor match.

    This isn't as good of an answer as I want, since I haven't figured out how to normalize it yet, but I'll update it if I figure it out, and it will give you an idea to look into.

提交回复
热议问题