Example #1
0
        private void closingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Filters filter1 = new Dilation();
            Filters filter2 = new Erosion();

            image = filter1.processImage(image);
            backgroundWorker1.RunWorkerAsync(filter2);
        }
Example #2
0
        private void topHatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap  new_image1 = (Bitmap)image.Clone();
            Bitmap  new_image2 = new Bitmap(image.Width, image.Height);
            Filters filter1    = new Erosion();
            Filters filter2    = new Dilation();

            image = filter1.processImage(image);
            image = filter2.processImage(image);

            for (int i = 0; i < image.Width; ++i)
            {
                for (int j = 0; j < image.Height; ++j)
                {
                    Color new_color = Color.FromArgb(filter1.clamp(new_image1.GetPixel(i, j).R - image.GetPixel(i, j).R, 0, 0xff),
                                                     filter1.clamp(new_image1.GetPixel(i, j).G - image.GetPixel(i, j).G, 0, 0xff),
                                                     filter1.clamp(new_image1.GetPixel(i, j).B - image.GetPixel(i, j).B, 0, 0xff));
                    image.SetPixel(i, j, new_color);
                }
            }

            pictureBox1.Image = image;
            pictureBox1.Refresh();
        }