Exemplo n.º 1
0
        public Color[,] ApplyContrastAdjustment(Color[,] Image)
        {
            ColorHistogram colorHistogram = new ColorHistogram(Image, InputImage.Size.Height, InputImage.Size.Width);

            for (int x = 0; x < InputImage.Size.Width; x++)
            {
                for (int y = 0; y < InputImage.Size.Height; y++)
                {
                    Color pixelColor   = Image[x, y];                       // Get the pixel color at coordinate (x,y)
                    int   Rnew         = (pixelColor.R - colorHistogram.ArLow) * (255 / (colorHistogram.ArHigh - colorHistogram.ArLow));
                    int   Gnew         = (pixelColor.G - colorHistogram.AgLow) * (255 / (colorHistogram.AgHigh - colorHistogram.AgLow));
                    int   Bnew         = (pixelColor.B - colorHistogram.AbLow) * (255 / (colorHistogram.AbHigh - colorHistogram.AbLow));
                    Color updatedColor = Color.FromArgb(Rnew, Gnew, Bnew);
                    Image[x, y] = updatedColor;
                    progressBar.PerformStep();
                }
            }
            return(Image);
        }
Exemplo n.º 2
0
        public Color[,] ApplyEqualization(Color[,] Image)
        {
            ColorHistogram colorHistogram = new ColorHistogram(Image, InputImage.Size.Height, InputImage.Size.Width);

            for (int y = 0; y < InputImage.Size.Height; y++)
            {
                for (int x = 0; x < InputImage.Size.Width; x++)
                {
                    Color  pixelColor   = Image[x, y];                      // Get the pixel color at coordinate (x,y)
                    int    R            = pixelColor.R;
                    int    G            = pixelColor.G;
                    int    B            = pixelColor.B;
                    double _255_MN      = (double)255 / (InputImage.Size.Width * InputImage.Size.Height);
                    double newR         = colorHistogram.CummulativeHistogramR[R] * _255_MN;
                    double newG         = colorHistogram.CummulativeHistogramG[G] * _255_MN;
                    double newB         = colorHistogram.CummulativeHistogramB[B] * _255_MN;
                    Color  updatedColor = Color.FromArgb((int)newR, (int)newG, (int)newB);
                    Image[x, y] = updatedColor;
                    progressBar.PerformStep();
                }
            }
            return(Image);
        }