aforge.net中的过滤器不支持源像素格式 [英] Source pixel format is not supported by the filter in aforge.net

查看:187
本文介绍了aforge.net中的过滤器不支持源像素格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Aforge.net开发一个LPR系统,我想在我的图像上应用一个滤镜,就像在这里看到的那样:

I am trying to develop an LPR system using Aforge.net ,i want to apply a filter on my image as you can see here :

            Bitmap a = new Bitmap(@"C:\Users\Public\Pictures\Sample Pictures\1.png");
            SobelEdgeDetector filter = new SobelEdgeDetector();
            filter.ApplyInPlace(a);
            pictureBox1.Image = a;

但运行后出现此错误:

Source pixel format is not supported by the filter.

我在aforge.net上是个新手.

I am so new in aforge.net.

推荐答案

As you can see from this API documentation page, the SobolEdgeDetector filter only supports 8bpp grayscale images.

要应用滤镜,因此需要先将图像转换为8bpp并转换为灰度,例如:

To apply the filter, you therefore need to convert your image to 8bpp and grayscale first, for example like this:

Bitmap a = AForge.Imaging.Image.Clone(
    new Bitmap(@"C:\Users\Public\Pictures\Sample Pictures\1.png"),
    PixelFormat.Format8bppIndexed);
AForge.Imaging.Image.SetGrayscalePalette(a);

这篇关于aforge.net中的过滤器不支持源像素格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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