static void DoErosion(ConvolutionWindow window, ImageData toCompute) { List <Color> colorList = new List <Color>(); for (int Yindex = 0; Yindex < toCompute.image.Height; Yindex++) { for (int Xindex = 0; Xindex < toCompute.image.Width; Xindex++) { window.sumElements.Clear(); window.ConvolutionWindowPixelsSum(toCompute.image, Xindex, Yindex); int min = window.sumElements.Min(); colorList.Add(Color.FromArgb(min, min, min)); } } int indexColor = 0; for (int yIndex = 0; yIndex < toCompute.image.Height; yIndex++) { for (int xIndex = 0; xIndex < toCompute.image.Width; xIndex++) { toCompute.image.SetPixel(xIndex, yIndex, colorList[indexColor]); indexColor++; } } }
static void DoMedianFilter(ConvolutionWindow window, ImageData toCompute) { for (int yIndex = 0; yIndex < toCompute.image.Height; yIndex++) { for (int xIndex = 0; xIndex < toCompute.image.Width; xIndex++) { window.pixelsCounter = 0; window.sumElements.Clear(); window.ConvolutionWindowPixelsSum(toCompute.image, xIndex, yIndex); int sum = (window.sumElements.Sum()) / window.pixelsCounter; Color pixelColor = Color.FromArgb(sum, sum, sum); toCompute.image.SetPixel(xIndex, yIndex, pixelColor); } } }