Answer the question
In order to leave comments, you need to log in
How to convert Bitmap to IplImage?
Actually, there is a certain Bitmap (with pixel format Format8bppIndexed: after conversion to Grayscale). How do I convert it to IplImage (OpenCV image format).
Tried like this:
public static Bitmap Binaryze(Bitmap inBitmap)
{
var g = new GrayscaleY();
var inGray = g.Apply(inBitmap);
var inPtr = IntPtr.Zero;
var bd = inGray.LockBits(new Rectangle(0, 0, inGray.Width, inGray.Height), ImageLockMode.ReadWrite,
PixelFormat.Format8bppIndexed);
try
{
inPtr = bd.Scan0;
var b1 = Sauvola.Convert(inPtr, 15, 0.05, 256);
var b2 = Benrsen.Convert(inPtr, 3, 100);
inGray.UnlockBits(bd);
...
}
...
}
public class Sauvola
{
public static Bitmap Convert(IntPtr src, int Size = 31, double K = 0.9, int R = 32)
{
var srcImage = new IplImage(src, true);
var imgSaulova = new IplImage(srcImage.Size, BitDepth.U8, 1); //вот тут ошибка. Очевидно, что srcImage вышел каким-то "не таким"
Binarizer.SauvolaFast(srcImage, imgSaulova, Size, K, R);
return imgSaulova.ToBitmap();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question