Example #1
0
        public override Bitmap ProcessImage(Bitmap SourceImage, BackgroundWorker worker)
        {
            ClosingFilter closing = new ClosingFilter(kernel);

            Bitmap ResultImage      = new Bitmap(SourceImage.Width, SourceImage.Height);
            Bitmap WorkClosingImage = closing.ProcessImage(SourceImage, worker);

            int R, G, B;

            for (int i = 0; i < SourceImage.Width; i++)
            {
                for (int j = 0; j < SourceImage.Height; j++)
                {
                    Color SourceColor  = SourceImage.GetPixel(i, j);
                    Color ClosingColor = WorkClosingImage.GetPixel(i, j);

                    R = Clamp(ClosingColor.R - SourceColor.R, 0, 255);
                    G = Clamp(ClosingColor.G - SourceColor.G, 0, 255);
                    B = Clamp(ClosingColor.B - SourceColor.B, 0, 255);

                    ResultImage.SetPixel(i, j, Color.FromArgb(R, G, B));
                }
            }

            return(ResultImage);
        }
Example #2
0
        private void closingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Can_Use_Struct_Elem)
            {
                MessageBox.Show("Необходимо сначала задать структурный элемент!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            button1.Enabled = true;
            Filter filter = new ClosingFilter(struct_kernel);

            backgroundWorker1.RunWorkerAsync(filter);
        }