How to find images with similar color using Python and PIL?

I have many images in a folder, and I would like to find images with a similar color with a pre-selected image.

I would like to do something like:

python find_similar.py sample.jpg

and return something like:

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

Is this doable?

+3
source share
2 answers

I can’t give you a canned solution, but here is a corner to solve the problem. This is not PIL-specific, and it can be completely fictitious since I have no experience in image processing.

  • Quantize the color in the image. This gives you a palette that encodes image color information without form information.

  • , . , , .

  • .

, .

+4

fooobar.com/questions/42420/..., Python PIL.

, ImageChops PIL difference :

import Image
import ImageChops

im1 = Image.open("original.jpg")
im2 = Image.open("sample.jpg")

diff = ImageChops.difference(im2, im1)

.

fooobar.com/questions/42418/..., .

+1

All Articles