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(); }
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); }
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(); }