Ehsan Akbar
Ehsan Akbar

Reputation: 7299

Source pixel format is not supported by the filter in aforge.net

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;

but after running i got this error:

Source pixel format is not supported by the filter.

I am so new in aforge.net.

Upvotes: 2

Views: 9022

Answers (1)

Anders Gustafsson
Anders Gustafsson

Reputation: 15981

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

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);

Upvotes: 10

Related Questions