Compare two images, where the one is slightly cropped (zoomed)
Im using the image library rmagick for ruby to compare two images.
They way I'm usually doing it, is by using the difference method:
require 'rmagick'
img1.difference(img2)
#=> [238.738932291668, 0.001389172567175018, 0.0184313725490196]
The above example is the output of two images which is most certainly the
same. This used to work very well for me, until I stumbled into a new
scenario, that this method does not handle very well - if the images are
the same (even same size), but one of them has been cropped e.g. 10px of
the border. Now suddenly, even though the two images look exactly the same
to the human eye, the computer will think they are very different, because
one of the images has been cropped just a small bit.
Is there anyway I can handle this situation, so I will still detect that
it's the same image, even though one of them has been cropped a little?
No comments:
Post a Comment