Algorithmix.Forensics.OCR.Preprocess C# (CSharp) Method

Preprocess() public method

OCR Preprocessing, currently this involves binary threholding a gray scaled image using the Otsu Method
public Preprocess ( byte>.Image image ) : byte>.Image
image byte>.Image Image to be preprocessed
return byte>.Image
        public Image<Gray, byte> Preprocess(Image<Bgra, byte> image)
        {
            Image<Gray, byte> gray = Filter.RgbToGray(image);
            Image<Gray, byte> thresh = Filter.Threshold(gray);
            //Filter.EmbossText(thresh);
            gray.Dispose();
            return thresh;
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 ///   Execute OCR on a given image, this static member will process the image,
 ///   Safely open, execute and dispose a Tesseract Object and store the result
 ///   in a new OcrData object.
 /// </summary>
 /// <param name="original"> Image to be OCR-ed </param>
 /// <param name="mode"> Accuracy setting </param>
 /// <param name="lang"> Language of text for OCR Language Model </param>
 /// <param name="enableTimer"> Measure the Scantime for Diagnostic purposes </param>
 /// <returns> </returns>
 public static OcrData Recognize(Bitmap original,
     Accuracy mode = Accuracy.High,
     string lang = "eng",
     bool enableTimer = false)
 {
     Image<Bgra, byte> img = new Image<Bgra, byte>(original);
     Image<Gray, byte> processed;
     Tesseract.Charactor[] chars;
     String text;
     long confidence;
     long scantime = Int64.MinValue;
     using (OCR ocr = new OCR(mode, lang, enableTimer))
     {
         processed = ocr.Preprocess(img);
         ocr.Scan(processed);
         confidence = ocr.OverallCost();
         chars = ocr.Charactors();
         text = ocr.Text();
         if (enableTimer)
         {
             scantime = ocr.Elapsed();
             ocr.Stop();
         }
     }
     img.Dispose();
     if (scantime == Int64.MinValue)
     {
         return new OcrData(processed, chars, text, confidence);
     }
     return new OcrData(processed, chars, text, confidence, scantime);
 }
All Usage Examples Of Algorithmix.Forensics.OCR::Preprocess