示例#1
0
        public override Bitmap ProcessImage(Bitmap SourceImage, BackgroundWorker worker)
        {
            DilationFilter dilation = new DilationFilter(kernel);
            ErosionFilter  erosion  = new ErosionFilter(kernel);

            Bitmap ResultImage = new Bitmap(SourceImage.Width, SourceImage.Height);

            Bitmap ImageDilation = dilation.ProcessImage(SourceImage, worker);
            Bitmap ImageErosion  = erosion.ProcessImage(SourceImage, worker);

            int R, G, B;

            for (int i = 0; i < SourceImage.Width; i++)
            {
                for (int j = 0; j < SourceImage.Height; j++)
                {
                    Color ColorDilation = ImageDilation.GetPixel(i, j);
                    Color ColorErosion  = ImageErosion.GetPixel(i, j);

                    R = Clamp(ColorDilation.R - ColorErosion.R, 0, 255);
                    G = Clamp(ColorDilation.G - ColorErosion.G, 0, 255);
                    B = Clamp(ColorDilation.B - ColorErosion.B, 0, 255);

                    ResultImage.SetPixel(i, j, Color.FromArgb(R, G, B));
                }
            }
            return(ResultImage);
        }
示例#2
0
        public override Bitmap ProcessImage(Bitmap SourceImage, BackgroundWorker worker)
        {
            Bitmap ResultImage = new Bitmap(SourceImage.Width, SourceImage.Height);
            Filter erosion     = new ErosionFilter(kernel);
            Filter dilation    = new DilationFilter(kernel);

            ResultImage = dilation.ProcessImage(SourceImage, worker);
            ResultImage = erosion.ProcessImage(ResultImage, worker);

            return(ResultImage);
        }