Пример #1
0
        public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            Filters di = new Dilation(kernel);
            Filters er = new Erosion(kernel);

            Bitmap tempDi  = new Bitmap(sourceImage.Width, sourceImage.Height);
            Bitmap tempEr  = new Bitmap(sourceImage.Width, sourceImage.Height);
            Bitmap tempRes = new Bitmap(sourceImage.Width, sourceImage.Height);


            tempDi = di.processImage(sourceImage, worker);
            tempEr = er.processImage(sourceImage, worker);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                worker.ReportProgress((int)((float)i / tempRes.Width * 100));

                if (worker.CancellationPending)
                {
                    return(null);
                }
                for (int j = 0; j < sourceImage.Height; j++)
                {
                    tempRes.SetPixel(i, j, Color.FromArgb(Clamp(tempDi.GetPixel(i, j).R - tempEr.GetPixel(i, j).R, 0, 255),
                                                          Clamp(tempDi.GetPixel(i, j).G - tempEr.GetPixel(i, j).G, 0, 255),
                                                          Clamp(tempDi.GetPixel(i, j).B - tempEr.GetPixel(i, j).B, 0, 255)));
                }
            }



            return(tempRes);
        }
Пример #2
0
        public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            Dilation di = new Dilation(kernel);
            Erosion  er = new Erosion(kernel);

            return(er.processImage(di.processImage(sourceImage, worker), worker));
        }
Пример #3
0
        public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            Dilation di = new Dilation(kernel);
            Erosion  er = new Erosion(kernel);

            Bitmap image1 = er.processImage(di.processImage(sourceImage, worker), worker);
            Bitmap image2 = di.processImage(er.processImage(sourceImage, worker), worker);


            //image1 = Invert(image1,worker);

            return(ResultGrad(image2, image1, worker));
        }
Пример #4
0
        private void cToolStripMenuItem_Click(object sender, EventArgs e)
        {
            float[,] kernel = new float[size, size];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    kernel[j, i] = (float)(Convert.ToDouble(dataGridView1.Rows[i].Cells[j].Value));
                }
            }

            stack.Push(image);
            Filters filter = new Erosion(kernel);

            backgroundWorker1.RunWorkerAsync(filter);
        }