Я пытаюсь этот пример, но у меня возникла ошибка «Формат исходного пикселя не поддерживается фильтром», и чтобы решить эту проблему, я попытался с помощью этих ответов , но получил ошибку с заголовком , то я попытался решить это с помощью этих ответов . Но мне не повезло, и я продолжаю получать эту ошибку.
Может ли кто-нибудь дать мне решение?
Вот код:
// Open your image
string path = "sample2.jpg"; //taken from first example links initial image.
Bitmap image = (Bitmap)Bitmap.FromFile(path);
// The original bitmap with the wrong pixel format.
// You can check the pixel format with originalBmp.PixelFormat
//Bitmap originalBmp = new (Bitmap)Image.FromFile("YourFileName.gif");
// Create a blank bitmap with the same dimensions
Bitmap tempBitmap = new Bitmap(image.Width, image.Height);
// From this bitmap, the graphics can be obtained, because it has the right PixelFormat
using (Graphics g = Graphics.FromImage(tempBitmap))
{
// Draw the original bitmap onto the graphics of the new bitmap
g.DrawImage(image, 0, 0);
// Use g to do whatever you like
//g.DrawLine(...);
}
//Bitmap EditableImg = new Bitmap(image);
Bitmap a = AForge.Imaging.Image.Clone(tempBitmap, PixelFormat.Format8bppIndexed); //currently getting titled error here.
AForge.Imaging.Image.SetGrayscalePalette(a);
// create filter
DifferenceEdgeDetector filter = new DifferenceEdgeDetector();
// apply the filter
filter.ApplyInPlace(image);
изображение ошибки для справки: ![enter image description here](https://i.stack.imgur.com/fyxBN.png)