public override Bitmap procImg(Bitmap sourceImage, bool[,] mask, int MW, int MH /*, BackgroundWorker worker*/) { MathMorf eros = new Erosion(); MathMorf dil = new Dilation(); Bitmap result = new Bitmap(sourceImage.Width, sourceImage.Height); result = eros.procImg(sourceImage, mask, MW, MH /*,worker*/); result = dil.procImg(result, mask, MW, MH /*,worker*/); return(result); }
public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker) { Bitmap resultImage = new Bitmap(sourceImage.Width, sourceImage.Height); Filters erosion = new Erosion(matr); Filters dilat = new Dilation(matr); //расширение Bitmap result = dilat.processImage(sourceImage, worker); //сужение result = erosion.processImage(result, worker); return(result); }
private void dirationToolStripMenuItem_Click(object sender, EventArgs e) { bool[,] mask = new bool[3, 3]; mask[0, 0] = false; mask[0, 1] = true; mask[0, 2] = false; mask[1, 0] = true; mask[1, 1] = true; mask[1, 2] = true; mask[2, 0] = false; mask[2, 1] = true; mask[2, 2] = false; MathMorf dil = new Dilation(); //backgroundWorker2.RunWorkerAsync(dil); Bitmap resultImage = dil.procImg(image, mask, 3, 3 /*,backgroundWorker2*/); pictureBox1.Image = resultImage; pictureBox1.Refresh(); }
public override Bitmap procImg(Bitmap sourceImage, bool[,] mask, int MW, int MH /*, BackgroundWorker worker*/) { MathMorf eros = new Erosion(); MathMorf dil = new Dilation(); Bitmap res1 = new Bitmap(sourceImage.Width, sourceImage.Height); Bitmap res2 = new Bitmap(sourceImage.Width, sourceImage.Height); Bitmap result = new Bitmap(sourceImage.Width, sourceImage.Height); res1 = dil.procImg(sourceImage, mask, MW, MH /*,worker*/); res2 = eros.procImg(sourceImage, mask, MW, MH /*,worker*/); for (int y = 0; y < sourceImage.Height; y++) { for (int x = 0; x < sourceImage.Width; x++) { result.SetPixel(x, y, Color.FromArgb(255, res1.GetPixel(x, y).R - res2.GetPixel(x, y).R, res1.GetPixel(x, y).G - res2.GetPixel(x, y).G, res1.GetPixel(x, y).B - res2.GetPixel(x, y).B)); } } return(result); }
private void расширениеToolStripMenuItem_Click(object sender, EventArgs e) { Morphology filter = new Dilation(); backgroundWorker1.RunWorkerAsync(filter); }