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 void ApplyLUT(int[] rLUT, int[] gLUT, int[] bLUT) { 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.ChangeColors(rLUT[pixel.Red], gLUT[pixel.Green], bLUT[pixel.Blue]); DrawPixel(pixel); } } UpdateImage(); UpdatePixelMatrix(); }