public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker) { Bitmap result = new Bitmap(sourceImage.Width, sourceImage.Height); Filters filter1 = new Dilation(mask); Bitmap result1 = filter1.processImage(sourceImage, worker); Filters filter2 = new Erosion(mask); Bitmap result2 = filter2.processImage(sourceImage, worker); for (int i = 0; i < sourceImage.Width; i++) { worker.ReportProgress((int)((float)i / sourceImage.Width * 100)); if (worker.CancellationPending) { return(null); } for (int j = 0; j < sourceImage.Height; j++) { int newR = Clamp(result1.GetPixel(i, j).R - result2.GetPixel(i, j).R, 0, 255); int newG = Clamp(result1.GetPixel(i, j).G - result2.GetPixel(i, j).G, 0, 255); int newB = Clamp(result1.GetPixel(i, j).B - result2.GetPixel(i, j).B, 0, 255); result.SetPixel(i, j, Color.FromArgb(newR, newG, newB)); } } return(result); }
public override Bitmap processImage(Bitmap sourceImage, BackgroundWorker worker) { Bitmap resultImage = new Bitmap(sourceImage.Width, sourceImage.Height); Filters filter1 = new Dilation(mask); Bitmap result = filter1.processImage(sourceImage, worker); Filters filter2 = new Erosion(mask); result = filter2.processImage(result, worker); return(result); }
private void расширениеToolStripMenuItem_Click(object sender, EventArgs e) { Filters filter = new Dilation(StructElem); backgroundWorker1.RunWorkerAsync(filter); }