Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        private void erosionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Can_Use_Struct_Elem)
            {
                MessageBox.Show("Необходимо сначала задать структурный элемент!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            button1.Enabled = true;
            Filter filter = new ErosionFilter(struct_kernel);

            backgroundWorker1.RunWorkerAsync(filter);
        }