Link to home
Start Free TrialLog in
Avatar of Suhas .
Suhas .Flag for United States of America

asked on

comparing two images

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.
SOLUTION
Avatar of cup
cup

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Infinity08
>> 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.
Avatar of Razor2k5
Razor2k5

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.
Avatar of Suhas .

ASKER

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?
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Suhas .

ASKER

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