예제 #1
0
        public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            Filters filter1 = new Dilation(mask);
            Bitmap  result  = filter1.processImage(sourceImage, worker);
            Filters filter2 = new Erosion(mask);

            result = filter2.processImage(result, worker);
            return(result);
        }
예제 #2
0
        public override Bitmap processImg(Bitmap img, BackgroundWorker worker)
        {
            Filter filter1 = new Dilatation(kernel);
            Bitmap res     = filter1.processImg(img, worker);
            Filter filter2 = new Erosion(kernel);

            res = filter2.processImg(res, worker);

            return(res);
        }
예제 #3
0
        public override Bitmap processImg(Bitmap img, BackgroundWorker worker)
        {
            float  resR; float resG; float resB;
            Filter filter = new Erosion(kernel);
            Bitmap res    = filter.processImg(img, worker);

            for (int i = 0; i < img.Width; i++)
            {
                for (int j = 0; j < img.Height; j++)
                {
                    resR = img.GetPixel(i, j).R - res.GetPixel(i, j).R;
                    resG = img.GetPixel(i, j).G - res.GetPixel(i, j).G;
                    resB = img.GetPixel(i, j).B - res.GetPixel(i, j).B;
                    res.SetPixel(i, j, Color.FromArgb(Clamp((int)resR, 0, 255), Clamp((int)resG, 0, 255), Clamp((int)resB, 0, 255)));
                }
            }

            return(res);
        }
예제 #4
0
파일: Form2.cs 프로젝트: Alexey42/CG_lab1
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 main = this.Owner as Form1;

            int[,] k = new int[3, 3];

            int.TryParse(textBox1.Text, out k[0, 0]);
            int.TryParse(textBox2.Text, out k[0, 1]);
            int.TryParse(textBox3.Text, out k[0, 2]);
            int.TryParse(textBox4.Text, out k[1, 0]);
            int.TryParse(textBox5.Text, out k[1, 1]);
            int.TryParse(textBox6.Text, out k[1, 2]);
            int.TryParse(textBox7.Text, out k[2, 0]);
            int.TryParse(textBox8.Text, out k[2, 1]);
            int.TryParse(textBox9.Text, out k[2, 2]);

            Filter filter = null;

            if (name == "Erosion")
            {
                filter = new Erosion(k);
            }
            if (name == "Dilatation")
            {
                filter = new Dilatation(k);
            }
            if (name == "Opening")
            {
                filter = new Opening(k);
            }
            if (name == "Closing")
            {
                filter = new Closing(k);
            }
            if (name == "TopHat")
            {
                filter = new TopHat(k);
            }
            this.Close();
            main.backgroundWorker1.RunWorkerAsync(filter);
        }
예제 #5
0
        public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            float   resultR;
            float   resultG;
            float   resultB;
            Filters filter = new Erosion(mask);
            Bitmap  result = filter.processImage(sourceImage, worker);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                for (int j = 0; j < sourceImage.Height; j++)
                {
                    resultR = sourceImage.GetPixel(i, j).R - result.GetPixel(i, j).R;
                    resultG = sourceImage.GetPixel(i, j).G - result.GetPixel(i, j).G;
                    resultB = sourceImage.GetPixel(i, j).B - result.GetPixel(i, j).B;
                    result.SetPixel(i, j, Color.FromArgb(
                                        Clamp((int)resultR, 0, 255),
                                        Clamp((int)resultG, 0, 255),
                                        Clamp((int)resultB, 0, 255)));
                }
            }
            return(result);
        }
예제 #6
0
        private void сужениеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Filters filter = new Erosion(structElem);

            backgroundWorker1.RunWorkerAsync(filter);
        }