两个位图图像的逻辑与 [英] Logical Andof two bitmap images

查看:73
本文介绍了两个位图图像的逻辑与的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以取两个位图的AND吗?
我正在尝试这段代码,但无法正常运行
公共静态位图AND(位图image1,位图image2)
{
位图img =(位图)(image1&image2);
返回img;
}

如果有人可以帮助我
在此先感谢.

我正在使用aforge.net.

can we take AND of two bitmaps
iam trying this code but it isn''t working
public static Bitmap AND(Bitmap image1, Bitmap image2)
{
Bitmap img=(Bitmap)(image1 & image2);
return img;
}

if any one can help me
thanks in advance.

i am using aforge.net. Is there any function which performs logical AND?

推荐答案

我认为您的意思是按位AND?一些图像库(如果我没有记错的话,一个用于iPhone的图像库)可以通过选择最亮或最暗的颜色并将其用于结果图像来按像素组合图像.但是,如果您使用的是普通C#,则必须创建一个新图像,并根据应用于其他两个图像中相应像素的某种逻辑来设置其中的每个像素.例如,您可以选择最亮的像素,然后使用它来设置结果图像中的像素.或者,您可以获取像素颜色的位表示形式,并将它们组合在一起,然后将位表示形式转换回颜色值,并将其设置在结果图像中.
I think you mean bitwise AND? Some image libraries (one for the iPhone, if I remember correctly) can combine images on a per-pixel basis by selecting the brightest or darkest color and using that in the result image. However, if you are using plain C#, you''ll have to create a new image and set each pixel in it according to some logic you apply to corresponding pixels in the other two images. For example, you could select the brightest pixels and use that to set the pixel in the result image. Or, you could get a bit representation of the color of the pixels, AND them together, then convert the bit representation back to a color value and set that in the result image.


谢谢非常

实际上我已经实现了代码.但是我一直在寻找一些更有效的代码,因为性能是我正在研究的项目中的一个问题.它与实时视频处理有关.
Thank you very much

actually i have implemented the code. but i was looking for some more efficient code because performance is an issue in the project i am working on. it is related to real time video processing.


如果您正在寻找原始速度,那么这是像素着色器的不错选择. XNA和DirectX是我所知的将像素着色器与代码集成的唯一选择,但是我并不是该领域的专家(例如,我从未在DirectX中尝试过,并且仅制作了1个像素着色器)在XNA中).如果您对此有疑问,请提出一个新问题(当然,您自己研究之后),因为它可能需要一些工作才能启动并运行.

仅供参考,像素着色器通过对像素应用操作来工作.您为这些操作定义逻辑(例如,按位与).然后,该逻辑将在图形卡上执行.现代图形卡能够一次执行很多像素着色器操作,因此这将是最快的方法.
If you are looking for raw speed, then this is a good candidate for a pixel shader. XNA and DirectX are the only options I know of for integrating pixel shaders with your code, but I''m not really an expert in that area (e.g., I''ve never tried it in DirectX, and have only made 1 pixel shader in XNA). If you have questions about that, start a new question (after researching it yourself, of course), as it could take some work to get that up and running.

FYI, a pixel shader works by applying operations on pixels. You define the logic for those operations (e.g., a bitwise AND). That logic then gets executed on the graphics card. Modern graphics cards are able to perform quite a few of those pixel shader operations at once, so this would be the fastest approach.


这篇关于两个位图图像的逻辑与的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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