WilsonKoder111
WilsonKoder111

Reputation: 372

Python - Best way to find similar images in a directory

Here is the effect I am trying to achieve - Imagine a user submits an image, then a python script to cycle through each JPEG/PNG for a similar image in the current working directory.

Close to how Google image search works (when you submit your image and it returns similar ones). Should I use PIL or OpenCV?

Preferably using Python3.4 by the way, but Python 2.7 is fine.

Wilson

Upvotes: 13

Views: 14587

Answers (2)

erdogant
erdogant

Reputation: 1694

I created the undouble library in Python which seems a match for your issue.

It uses Hash functions to detect (near-)identical images in for example a directory. It works using a multi-step process of pre-processing the images (grayscaling, normalizing, and scaling), computing the image hash, and the grouping of images based on a threshold value.

Upvotes: 0

v0rtex20k
v0rtex20k

Reputation: 1121

I mean, why not use both? It's trivial to convert PIL images into OpenCV images and vice-versa, and both have niche functions that can make your life easier. Pair them up with sklearn and numpy, and you're cooking with gas.

Upvotes: 1

Related Questions