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

ToGrayscale() public method

Filter: Grayscale convert to grayscale
public ToGrayscale ( ) : void
return void
        public void ToGrayscale()
        {
            var filter = new Grayscale(0.2125, 0.7154, 0.0721); // create filter
            var grayImage = filter.Apply(Image); // apply the filter
            Image = grayImage;
            Save("grayed");
        }

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::ToGrayscale