OcrLibrary.Helpers.Screenshot.ToBinary C# (CSharp) Method

ToBinary() public method

Filter: Threshold (Binary) Binarize the image (threshold)
public ToBinary ( ) : void
return void
        public void ToBinary()
        {
            var filter = new Threshold(230); // create filter
            filter.ApplyInPlace(Image); // apply the filter
            Save("binarized");

            /*
             * Note: Since the filter can be applied as to 8 bpp and to 16 bpp images, the Threshold Value value
             * should be set appropriately to the pixel format. In the case of 8 bpp images the threshold value
             * is in the [0, 255] range, but in the case of 16 bpp images the threshold value is in the [0, 65535] range.
             */
        }

Usage Example

示例#1
0
        /// <summary>
        /// run Ocr-Preprocessing filters
        /// TODO: run pre-OCR optimizations on separate thread/process
        /// </summary>
        /// <param name="screenshot"></param>
        private static void RunOcrPreProcessing(Screenshot screenshot)
        {
            //return;
            try
            {
                //screenshot.Crop(); //TODO: re-enable when screenshotter works again
                //screenshot.Resize(); // resize to 300dpi //TODO: neccessary for screenshot?

                screenshot.ToGrayscale();
                //screenshot.SubtractMedianBlur(); //TODO: how to make it work?
                screenshot.ToBinary();
            }
            catch (Exception e)
            {
                Logger.WriteToLogFile(e);
            }
        }
All Usage Examples Of OcrLibrary.Helpers.Screenshot::ToBinary