应用differentFilter时出现错误 [英] i have an error when applying differenceFilter

查看:115
本文介绍了应用differentFilter时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码

i have this code

class Program
    {
        private GrayscaleBT709 grayscaleFilter = new GrayscaleBT709();
        private Difference differenceFilter = new Difference();
        private Threshold thresholdFilter = new Threshold(70);
        private Opening openingfilter = new Opening();
        public Program()
        {
            Bitmap image = new Bitmap("d:\\m.bmp");
            Bitmap backgroundFrame = new Bitmap("d:\\bc.bmp");
            grayscaleFilter.Apply(backgroundFrame);
            Bitmap currentFrame = grayscaleFilter.Apply(image);
            differenceFilter.OverlayImage = backgroundFrame;

               Bitmap motionObjectsImage = differenceFilter.Apply(currentFrame);


           }
}


这段代码给我一个错误,是:
源图像和重叠图像必须具有相同的像素格式.
我该如何解决此错误?


this code give me an error that is :
source and overlay images must have same pixel format.
how can i solve this error?

推荐答案

您需要转换一张图像,以使两个图像具有相同的像素格式.您可以在此处查看转换功能:
http://bytes.com/topic/c-sharp/answers/276827-bitmap- pixelformat-conversion [^ ]

您可能需要稍作调整.
You need to convert one of the images so that both images have the same pixel format. You can have a look to a conversion function there:
http://bytes.com/topic/c-sharp/answers/276827-bitmap-pixelformat-conversion[^]

You will probably need to adapt it a little bit.


这篇关于应用differentFilter时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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