Ejemplo n.º 1
0
        public void BinarizationOperation(int threshold)
        {
            outBitmap = new WriteableBitmap(originalBitmap);
            outBitmap.Lock();
            byte MAX_COLOR = 0xFF;

            byte[] LUT = new byte[MAX_COLOR + 1];

            for (int i = threshold; i < MAX_COLOR + 1; i++)
            {
                LUT[i] = MAX_COLOR;
            }

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    RGBPixel pixel = pixelMatrix[x, y];
                    pixel.ToGrayscale2();
                    pixel.ChangeColors(LUT[pixel.Red]);
                    DrawPixel(pixel);
                }
            }
            UpdateImage();
        }
Ejemplo n.º 2
0
        public int[] GetGrayscaleHistogram()
        {
            byte MAX_COLOR = 0xFF;

            int[] h = new int[MAX_COLOR + 1];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    RGBPixel pixel = pixelMatrix[x, y];
                    pixel.ToGrayscale2();
                    h[pixel.Red]++;
                }
            }
            return(h);
        }
Ejemplo n.º 3
0
 public void GrayscaleOperation2()
 {
     outBitmap = new WriteableBitmap(originalBitmap);
     outBitmap.Lock();
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             RGBPixel pixel = pixelMatrix[x, y];
             pixel.ToGrayscale2();
             DrawPixel(pixel);
         }
     }
     UpdateImage();
     UpdatePixelMatrix();
 }