'Order images based on similarity

I have a lot of images in a folder that I would like to put in order based on how similar they are. The images are histological slides from a tissue microarray (for example: http://www.proteinatlas.org/images/36302/112008_A_6_6.jpg)

What I have tried: I take the first image, compare it to all and match it up with the best match. Then i take the closest match and do the same thing all over. To calculate similarity I have tried Structural similarity index and also Hashing (pHash, dHash) none of them work very well, but the hashing seems to be a bit better.

To put the images in order, I basically use a number of renaming and moving of images from one folder to another and deleting the ones I have already matched up.

What could I use instead of hashing or similarity index and how could I sort them without renaming, moving the files around or deleting them?



Solution 1:[1]

There is a lot of software available that is capable of comparing visual similarity of images and then sorting those images accordingly.

Here is one

Solution 2:[2]

This answer from a different question offers a a very promising approach.

Get a library like pHash to calculate an hash for each image, then order the images according to that hash. pHash is opensource, GPLv3, and it provides hashing algorithms tailored to image and music comparison.

This other discussion from Ycombinator also points out that:

  • libPuzzle is a (less valid, apparently) alternative
  • pHash/libphash is pretty slow, for what it does.
  • the most used methods for image comparison are SURF and SIFT, though at the time of the thread (2014) they were patent-encumbered, but they are apparently pretty simple to implement using opencv, so one might want to fiddle with that, even without a background in computer vision, to get some better insight into the issue.

Solution 3:[3]

I know it's been 5 years since you asked the question but here is a recent web tool I created with python Sortedimage. It seems we had the same problem.

Peace!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shawn
Solution 2
Solution 3 Hendy Saint-Jusna