I am using this code to improve an image and help the OCR process. Problem is for some reason, final image is always black.
Code: Select all
QuantizeSettings qs = new QuantizeSettings();
qs.ColorSpace = ColorSpace.Gray;
image.Quantize(qs);
image.ColorType = ColorType.Grayscale;
image.ContrastStretch(new Percentage(0), new Percentage(0));
QuantizeSettings qs2 = new QuantizeSettings();
MagickImage img2 = image.Clone();
qs2.ColorSpace = ColorSpace.Gray;
img2.Quantize(qs2);
img2.Negate();
img2.AdaptiveThreshold(15, 15, 10);
img2.ContrastStretch(new Percentage(0), new Percentage(0));
image.Composite(img2, CompositeOperator.CopyAlpha);
image.Opaque(new MagickColor(System.Drawing.Color.White), new MagickColor(System.Drawing.Color.White));
image.Alpha(AlphaOption.Activate);
image.Deskew(new Percentage(40));
image.Sharpen(Channels.Black);
P.S.
Actually, i am trying to implement this:
http://www.fmwconcepts.com/imagemagick/ ... /index.php
Thanks!