Solved

comparing two images

Posted on 2006-07-17
8
331 Views
Last Modified: 2010-04-15
please can anyone provide the code for comparing two images of any type(ppm,pgm,pbm,jpg etc..) and the output will be the number of pixel difference.

Thanks in advance.
0
Comment
Question by:Suhas .
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 11

Assisted Solution

by:cup
cup earned 50 total points
ID: 17127816
The way I'd approach this is to convert both the images to a common format an then compare them in the common format.

Have a look at the ImageMagick library - they convert everythng to .miff format which might be what you're looking for.  One thing about imagemagick - it relies on dynamic loading of DLLs.  If the DLLs are not there, it doesn't tell you - it just doesn't work.

Big images in high resolutions need tons of memory.  Make sure you have enough.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 17128111
>> The way I'd approach this is to convert both the images to a common format an then compare them in the common format.
The reason this is a better approach, is because all images are represented differently, and not all of them store the data pixel by pixel. Some are extrapolated, others use vectors. There's also compression to take into account. In the end it's easier to convert to eg. PNG or GIF like cup suggested.
0
 
LVL 2

Expert Comment

by:Razor2k5
ID: 17144286
Hi,

Try to serialize the data as a bit stream.
Then you perform an XOR operation and you got the results. Only different bit pairs are resulted.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:Suhas .
ID: 17144342
Yes,
using fopen we can get the data of two files and comparing byte by byte we get the no. of difference in bytes.

can you please send the code to comare two images of any type?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 17145454
That's a bit too much work for us to do it for you ... instead read the suggestion made by cup again, and try to work it out yourself. If you have specific questions and or problems about that, feel free to ask them in this thread, and we'll be glad to help you out with them.
0
 
LVL 3

Accepted Solution

by:
srinims earned 75 total points
ID: 17152003

hi,
    use gdiplus libraries from the microsoft to convert the images of any type to some common types.
 
   I think gdiplus itself would provide you the comparison methods.
   
   if do you want the difference in pixel means, i think the output also image.
 
   you should not use the general bitwise difference. hopefully u may aware of this,

   you have to make difference using RGB values. even RGB1 ~ RGB2 would not provide you the exact diffrences in images, what you have expected.

   for  that you have to convert the RGB format of the image in to HSB i.e Hue, Saturation and Brighness. And then you have to make hsb1~hsb2. then you have to convert the output RGB. That one only will provide you the exact difference in the image itself. Like extracting a image of man(object) from the background, using the two different image with man and without man.

   The things are bit complicated, but you can do


srini ms
0
 
LVL 9

Author Comment

by:Suhas .
ID: 17301667
Hi srinims,
can you just give me one example of how to use gdiplus?

also how to convert rgb to hsb and hsb1~hsb2 -> rgb

Thanks,
suhas
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question