4

I'm looking for a good way to analyze image similarity, using python. I'm NOT looking for a way to establish whether two images are identical. I'm just looking for a way to establish the similarity between two images (e.g., if two images are very similar they could be given a "grade" of 9/10; if they are completely unalike, they'll be given a very low index, such as 2/10). From some reading that I've done, the module ImageChops has been suggested - however, I haven't been able to find a way to download it. If anyone knows how to download it, or has a suggestion for other effective solutions, I'd greatly appreciate their advice!

Thanks in advance!

2 Answers 2

10

ImageChops is a module from PIL(Pillow). To use the ImageChops function you need to pip install Pillow OR easy_install Pillow OR download the src & extract the src then from CMD CD to the extracted folder & run python setup.py install.

To use the ImageChops you can do this from PIL import ImageChops you can read the document section

some basic usage example http://effbot.org/imagingbook/imagechops.htm

To check the difference between 2 images:

import Image from PIL import ImageChops im1 = Image.open("splash.png") im2 = Image.open("splash2.png") diff = ImageChops.difference(im2, im1) 

there's a compare images script, but its not a PIL; its on scipy module You may also check this script here

Sign up to request clarification or add additional context in comments.

2 Comments

How Do I save the difference Image?
In my code, I had to use: from PIL import Image instead of directly using import Image
3

ImageChops is an module belong to Python Image Library(PIL). Just note that there is no image similarity algorithm (except pixel-wise) built-in in ImageChops, instead, it is a tool you used to write your own algorithm. There is a greate article here: How can I quantify difference between two images?

The ImageChops module contains a number of arithmetical image operations, called channel operations (“chops”). These can be used for various purposes, including special effects, image compositions, algorithmic painting, and more. http://effbot.org/imagingbook/imagechops.htm

you can download the Python Image Library here. http://www.pythonware.com/products/pil/

There are precompiled package for windows user too. http://www.lfd.uci.edu/~gohlke/pythonlibs/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.