Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting if two images are visually identical

Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint, then one could hash image X and it would be a simple matter to see if it is in the database or not.

I know there is research around this issue, and some algorithms exist, but is there any tool, like a UNIX command line tool or a library I could use to compute such a hash without implementing some algorithm from scratch?

edit: relevant code from findimagedupes, using ImageMagick

try $image->Sample("160x160!"); try $image->Modulate(saturation=>-100); try $image->Blur(radius=>3,sigma=>99); try $image->Normalize(); try $image->Equalize(); try $image->Sample("16x16"); try $image->Threshold(); try $image->Set(magick=>'mono'); ($blob) = $image->ImageToBlob(); 

edit: Warning! ImageMagick $image object seems to contain information about the creation time of an image file that was read in. This means that the blob you get will be different even for the same image, if it was retrieved at a different time. To make sure the fingerprint stays the same, use $image->getImageSignature() as the last step.

like image 634
Bemmu Avatar asked Dec 03 '08 02:12

Bemmu


People also ask

How can I tell if two pictures are similar?

You can use the imagehash library to compare similar images. Since the images are not exactly the same, there will be some differences, so therefore we use a cutoff value with an acceptable maximum difference. That difference between the hash objects is the number of bits that are flipped.


1 Answers

findimagedupes is pretty good. You can run "findimagedupes -v fingerprint images" to let it print "perceptive hash", for example.

like image 62
sanxiyn Avatar answered Sep 30 '22 16:09

sanxiyn