如何从另一个在C#中减去一个位图/。NET? [英] How to subtract one bitmap from another in C#/.NET?

查看:160
本文介绍了如何从另一个在C#中减去一个位图/。NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个位图,通过算法的不同变化产生的。我想减去从另一个表现出的差异来创建第三位。

I have two bitmaps, produced by different variations of an algorithm. I'd like to create a third bitmap by subtracting one from the other to show the differences.

如何在.NET这样做吗?我看过了Graphics类及其所有选项,包括ImageAttributes类,我有一种预感它涉及到彩色矩阵或重新映射表功能。

How can this be done in .NET? I've looked over the Graphics class and all its options, including the ImageAttributes class, and I have a hunch it involves the color matrix or remap tables functionality.

有没有人有一个链接到一些例如code,也可以在正确的方向指向我?谷歌搜索并没有透露太多,除非我的谷歌福今天失败了我。

Does anyone have a link to some example code, or can point me in the right direction? A google search doesn't reveal much, unless my google-fu is failing me today.

推荐答案

真正的问题是,你想显示什么区别?如果你只需要在RGB颜色值进行操作,在我看来,最好的办法是只通过两个位图扫描和对比使用getPixel的色彩值,并使用SetPixel生成你的'差'的位图。也许你只是想减去值,并使用这些作为第三位新的颜色值。或者,也许你要计算出的亮度和使用。更妙的是,如果您有三个指标进行比较,分配每个人对颜色的RG和B组分。我用这个方法来分着色前。

The real question is, what differences do you want to show? If you just need to operate on RGB color values, the best bet in my opinion is to just scan through both bitmaps and compare the Color values using GetPixel, and use SetPixel to generate your 'difference' bitmap. Perhaps you simply want to subtract the values and use those as the new Color value for the third bitmap. Or perhaps you want to calculate out the luminosity and use that. Even better, if you have three metrics for comparison, assign each one to the R G and B components of the color. I've used this approach for fractal colorization before.

有其他的方法,但是这一次你只限于你的想象力。它可能不是最快的方法,但它听起来并不像表现是必要的这种情况。

There are other approaches, but with this one you are limited only to your imagination. It may not be the fastest approach, but it does not sound like performance is necessary for this scenario.

这篇关于如何从另一个在C#中减去一个位图/。NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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