[英]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.这是我想要实现的效果 - 假设用户提交了一个图像,然后是一个 python 脚本循环遍历每个 JPEG\/PNG 以获得当前工作目录中的类似图像。
Close to how Google image search works (when you submit your image and it returns similar ones).接近 Google 图片搜索的工作原理(当您提交图片并返回相似图片时)。 Should I use PIL or OpenCV?我应该使用 PIL 还是 OpenCV?
Preferably using Python3.4 by the way, but Python 2.7 is fine.顺便说一句,最好使用 Python3.4,但 Python 2.7 很好。
Wilson威尔逊
"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.将 PIL 图像转换为 OpenCV 图像是微不足道的,反之亦然,并且两者都具有可以让您的生活更轻松的小众功能。 Pair them up with sklearn and numpy, and you're cooking with gas.将它们与 sklearn 和 numpy 配对,你就可以用煤气做饭了。
Yes check out the undouble library!是的,请查看undouble库!
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.它使用预处理图像(灰度、归一化和缩放)、计算图像哈希以及基于阈值对图像进行分组的多步骤过程来工作。
Examples are available on the github page and sphinx pages but if you are looking for a guide, try this medium blog示例可在 github 页面和sphinx 页面上找到,但如果您正在寻找指南,请尝试这个中型博客
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.