Aspose.OCR.Examples.CSharp.FormattingAndManipulatingOCR.ExtractPreprocessedImages.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:ExtractPreprocessedImages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of OcrEngine
            OcrEngine ocrEngine = new OcrEngine();

            // Set the Image property by loading the image from file path location or an instance of MemoryStream 
            ocrEngine.Image = ImageStream.FromFile(dataDir + "sample1.jpg");
            ocrEngine.Config.SavePreprocessedImages = true;

            // Process the image
            if (ocrEngine.Process())
            {
                // Save binarized,filtered image on disc
                ocrEngine.PreprocessedImages.BinarizedImage.Save(dataDir + "BinarizedImage_out.png", System.Drawing.Imaging.ImageFormat.Png);
                ocrEngine.PreprocessedImages.FilteredImage.Save(dataDir + "FilteredImage_out.png", System.Drawing.Imaging.ImageFormat.Png);

                // Save image after removing non-textual fragments,  skew correction and textual block detection
                ocrEngine.PreprocessedImages.NonTextRemovedImage.Save(dataDir + "NonTextRemovedImage_out.png", System.Drawing.Imaging.ImageFormat.Png);
                ocrEngine.PreprocessedImages.RotatedImage.Save(dataDir + "RotatedImage_out.png", System.Drawing.Imaging.ImageFormat.Png);
                ocrEngine.PreprocessedImages.TextBlocksImage.Save(dataDir + "TextBlocksImage_out.png", System.Drawing.Imaging.ImageFormat.Png);
            }
            // ExEnd:ExtractPreprocessedImages
        }
    }
ExtractPreprocessedImages