如何使用Python和PIL查找具有相似颜色的图像? [英] How do I find images with a similar color using Python and PIL?

查看:353
本文介绍了如何使用Python和PIL查找具有相似颜色的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件夹中有很多图像,我想找到与预选图像颜色相近的图像。

I have a lot of images in a folder, and I would like to find images with a similar color to a pre chosen image.

我想成为能够做类似的事情:

I would like to be able to do something like:

python find_similar.py sample.jpg

并返回类似于:

234324.jpg
55.jpg
9945.jpg
345434.jpg
104.jpg

这可行吗?

推荐答案

我不能给你一个罐装解决方案,但这是一个解决的角度问题。它不是特定于PIL的,它可能完全是假的,因为我没有图像处理经验。

I cannot give you a canned solution, but here's an angle to tackle the problem. It's not PIL-specific, and it might be entirely bogus, since I have no experience in image processing.


  1. 执行颜色量化。这为您提供了一个调色板,用于对图像中的颜色信息进行编码,没有任何形状信息。

  1. Perform color quantization on the image. That gives you a palette that encodes the color information in the image without any shape information.

运行主成分分析,以获取颜色立方体中的主要组件。严格来说,你可以在没有量化的情况下运行它,但它可能太贵了。

Run a principal components analysis to get the dominant components in the color cube. Strictly, you could run this without quantization first, but it might be too expensive.

对不同图像的主要成分进行最小二乘拟合。 / p>

Do a least-squares fitting on the principal components of different images.

希望这有帮助。

这篇关于如何使用Python和PIL查找具有相似颜色的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆