AuScGen.Imaging.ImageProcessor.BinarizeImage C# (CSharp) Method

BinarizeImage() public method

public BinarizeImage ( int threshold ) : Bitmap
threshold int
return System.Drawing.Bitmap
        public Bitmap BinarizeImage(int threshold)
        {
            Threshold filter = new Threshold(threshold);
            //ConvertTOGrayScale(0.2125, 0.7154, 0.0721);
            Bitmap convertedImage = filter.Apply(ImageBitmap);
            ImageBitmap = convertedImage;
            return convertedImage;
        }

Usage Example

Beispiel #1
0
        static void Main(string[] args)
        {
            string imagepath = Directory.GetCurrentDirectory() + @"\Data";
            ImageProcessor imgProcessor = new ImageProcessor(new Bitmap(imagepath + @"\GoogleSample.jpg"));
            imgProcessor.ConvertTOGrayScale(0.2125, 0.7154, 0.0721);
            imgProcessor.ImageBitmap.Save(Directory.GetCurrentDirectory() + @"\Output\" + "test.bmp");
            imgProcessor.BinarizeImage(100);
            imgProcessor.ImageBitmap.Save(Directory.GetCurrentDirectory() + @"\Output\" + "test2.bmp");
            List<Blob> blobs = imgProcessor.ExtractBlob();
            imgProcessor.SaveBlobsToLocal(Directory.GetCurrentDirectory() + @"\Output\", imgProcessor.ExtractBlob());

            
            blobs.ForEach(blob => 
            {
                List<Rectangle> rectangles = imgProcessor.GetBlobRectangles(blob);
                
                foreach(Rectangle rect in rectangles)
                {
                    Highlight(rect);
                }
                
            });
            

            //Bitmap bmp1 = new Bitmap(imagepath + @"\Graph.png");
            //Bitmap grayImage = blob.ConvertTOGrayScale(0.2125, 0.7154, 0.0721, bmp1);
            ////grayImage.Save(Directory.GetCurrentDirectory() + @"\Output\" + "test.bmp");
            //Bitmap binarizedImage = blob.BinarizeImage(100, grayImage);
            ////binarizedImage.Save(Directory.GetCurrentDirectory() + @"\Output\" + "test2.bmp");

            //ImageProcessor blob2 = new ImageProcessor(binarizedImage);
            //var test2 = blob2.ExtractBlob(55, 130,0,0);
            //blob2.SaveBlobsToLocal(Directory.GetCurrentDirectory() + @"\Output", test2);
        }