Image Comparison using c++ or python

Question:

I am looking for a C++ or Python library to compare two JPEG or BMP formatted Images.
Here, I want to compare them pixel wise. For instance assume we have Image1 = 500 pixels, Image2 = 500 pixels; now i need to know the color values ie (RGB, R = 24, G = 15, B = 4) for each pixel and compare the same with image2 at the same location.

I also need to have tolerance values acting upon them, if they still have difference crossing this tolerance then i need to have the total percentage difference.

Is there a library out there ? If so please point me to that or give me any suggestions to start with.

Asked By: Santhosh Balasa

||

Answers:

I’d suggest OpenCV. It’s written in C, but there are bindings for Python as well. There are probably other solutions as well (e.g. doing it “by hand” yourself or using another library), but I’d say it’s by far the most popular imaging library available.

E.g. you could create a new image with the differences between both images and then count different pixels or judge your result depending on its colors etc.

Answered By: Mario

Did you try OpenCV ; it uses C++ .

Answered By: Sujay Ghosh

I might check out Python Image Library, the Image Module’s, getdata() and getpixel() sound like they’d be useful for you.

Answered By: ben author

If all you need to do is just comparison pixel-wise, you might achieve better performance by using numpy.

Numpy is an extremely fast python module that works with n-dimensional arrays (containing all the same type, as it is in the case of pixel data) and by operating on them element-wise.

So, "tell me were the alpha value of the pixels of two images differs by more than 0.5" would be translated in something like:

img_one[..., ALPHA] - img_two[..., ALPHA] > 0.5

HTH!

Answered By: mac
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.