Page 1 of 1

Process an image for better OCR, returns a black one...

Posted: 2017-03-23T05:25:08-07:00
by geko
Hello all!

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.ColorType = ColorType.Grayscale;
image.ContrastStretch(new Percentage(0), new Percentage(0));

QuantizeSettings qs2 = new QuantizeSettings();
MagickImage img2 = image.Clone();
qs2.ColorSpace = ColorSpace.Gray;
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.Deskew(new Percentage(40));
What am i doing wrong?

Actually, i am trying to implement this: ... /index.php


Re: Process an image for better OCR, returns a black one...

Posted: 2017-03-23T05:30:05-07:00
by dlemstra
You don't need to create that yourself. You can download a NuGet package with that script here: ... xtCleaner/. Be aware that you need to pay a small fee if you want to use it in a commercial project.