Example #1
0
 static void DoColoredMedianFilter(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.sumColoredElements.Clear();
             window.ConvolutionWindowPixelsSumForColoredFilters(toCompute.image, xIndex, yIndex);
             float    sum           = (window.sumColoredElements.Sum()) / window.pixelsCounter;
             HSVColor pixelHSVColor = HSVColor.RGBtoHSV(toCompute.image.GetPixel(xIndex, yIndex));
             Color    pixelColor    = HSVColor.HSVtoRGB(new HSVColor(pixelHSVColor.hue, pixelHSVColor.saturation, sum));
             toCompute.image.SetPixel(xIndex, yIndex, pixelColor);
         }
     }
 }