比较图像并突出显示差异 [英] Comparing Images and highlighting the differences

查看:83
本文介绍了比较图像并突出显示差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有一种方法可以比较2张图像并突出显示差异.我看了下面的文章,也想强调它们之间的区别.
使用GDI +比较图像 [

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

推荐答案

我希望您已经学习了如何在内存中锁定位图并使用原始图像数据来获得合理的性能?如果不是,请在此处查看代码示例: http://msdn.microsoft.com/en-us/library /5ey6h79d.aspx [ ^ ].首先要了解的是:由于性能问题,切勿使用GetPixel/SetPixel来达到类似目的.请注意可能不同的像素格式,请参见属性System.Drawing.Bitmap.PixelFormat.原则上,您可以比较不同的格式,只需查看每种格式的说明即可正确解释它们-您在所有此类处理中都处于较低的水平.

现在,该怎么办?

幼稚的问题是否要从每个组件的另一个图像中减去一个图像,并可选地将结果归一化.会起作用的.
一个问题是:一幅图像中的某些值较低,而另一幅图像中的某些值较低.一种方法是:您有两个图像I1I2,使用带符号的结果类型相减并将负值更改为零;创建两个差异图像I1-I2I2-I1;或者,减去并获得绝对值.

要进行更复杂的处理,请使用AForge.NET: http://www.aforgenet.com/ [
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


您可以逐像素比较它们,如果Image1Pixel的值与Image2Pixel不同,则可以通过更改像素值来更改颜色.应该使用不安全的代码来获得更好的性能.尽管请确保明智地管理内存和其他资源,因为.Net不会为您做到这一点.

这肯定假定图像的大小相同.如果它们的大小不同,则需要做更多的工作.网络上有很多工具,也有很多可供阅读的工具.我认为您应该花一些时间研究图像比较算法",然后为您选择最合适的图像.

刚刚注意到,由于您已经找到了可能适合您的文章,请在文章论坛下提问,以便作者可以为您提供帮助.
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.


这篇关于比较图像并突出显示差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆