Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is there a way to compare 2 images and also highlight the differences. I have looked at the following article and I want to highlight the differences also.
Comparing Images using GDI+[^]

Thank you
Posted

I hope you already learned how to lock bitmap in memory and work with raw image data to get reasonable performance? If not, see the code sample here: http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[^]. First thing to know: never use GetPixel/SetPixel for this is similar purposes, due to performance issues. Be careful with possibly different pixel formats, see the property System.Drawing.Bitmap.PixelFormat. In principle, you can compare different formats, just see the description of each to interpret them correctly — you work on the low level in all such processing.

Now, what to do with that?

The naive question if to subtract one image from another per component and optionally normalize the result. It will work.
One problem is: some values are lower in one image, some are lower on the other one. One approach is: it you have two images, I1 and I2, subtract using signed result type and change negative values to zero; create two differential images I1-I2 and I2-I1; alternatively, subtract and get the absolute value.

For more sophisticated processing, use AForge.NET: http://www.aforgenet.com/[^].

—SA
 
Share this answer
 
v2
You can possibly compare them pixel by pixel and if Image1Pixel has different value than Image2Pixel, you can change the color by changing pixel values. This should be done in using unsafe code to get better performance. Although be sure to manage the memory and other resources wisely since .Net won't do that for you.

This surely assumes that the images are of same size. If they are of different sizes, you will need to do some more work. There are a lot of tools available on web and a lot to read as well. I think you should spend time researching for "Image comparison algorithms" and choose the best fit for you.

Just noticed, since you have already found an article which possibly suits you, ask a question under article forum so that author can help you out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900