public Bitmap invertImage() { int[,] invertedMat = new int[Mat.GetLength(0), Mat.GetLength(1)]; ImageProcessor.CopyMat(ref invertedMat, ref Mat); for (int r = 0; r < invertedMat.GetLength(0); r++) { for (int c = 0; c < invertedMat.GetLength(1); c++) { invertedMat[r, c] = 255 - invertedMat[r, c]; } } Bitmap invertedImage = ImageProcessor.CopyImage(ViewedImage); if (isColorised) { Mat = invertedMat; GetViewedImage(); previewStages.Add(new PreviewState(stages, null, OriginalImage, ViewedImage, ColorisedImage, GrayscaleImage, CopyMat(), isColorised, brightness, contrast, saturation)); } else { Mat = invertedMat; GetViewedImage(); previewStages.Add(new PreviewState(stages, null, OriginalImage, ViewedImage, ColorisedImage, GrayscaleImage, CopyMat(), isColorised, brightness, contrast, saturation)); } return(invertedImage); }
public Bitmap updateImageBrightness(int brightness) { this.brightness = brightness; double brightnessFactor = 1 + ((double)brightness / (double)100.0); int[,] brightenedMat = new int[Mat.GetLength(0), Mat.GetLength(1)]; ImageProcessor.CopyMat(ref brightenedMat, ref Mat); for (int r = 0; r < brightenedMat.GetLength(0); r++) { for (int c = 0; c < brightenedMat.GetLength(1); c++) { brightenedMat[r, c] = (int)Math.Min(255, brightenedMat[r, c] * brightnessFactor); } } Bitmap brightenedImage = ImageProcessor.CopyImage(ViewedImage); if (isColorised) { Mat = brightenedMat; GetViewedImage(); previewStages.Add(new PreviewState(stages, null, OriginalImage, ViewedImage, ColorisedImage, GrayscaleImage, CopyMat(), isColorised, brightness, contrast, saturation)); } else { Mat = brightenedMat; GetViewedImage(); previewStages.Add(new PreviewState(stages, null, OriginalImage, ViewedImage, ColorisedImage, GrayscaleImage, CopyMat(), isColorised, brightness, contrast, saturation)); } return(brightenedImage); }
public static int[,] getEqualized(int[,] mat) { int mn = mat.GetLength(0) * mat.GetLength(1); float[] intensityFrequencies = new float[256]; int[,] equalizedHistogram = new int[mat.GetLength(0), mat.GetLength(1)]; ImageProcessor.CopyMat(ref equalizedHistogram, ref mat); calculateFrequencies(mn, mat, ref intensityFrequencies); buildEqualized(intensityFrequencies, ref equalizedHistogram); return(equalizedHistogram); }
void copyState(int index) { OriginalImage = previewStages[index].OriginalImage; ConvertToGrayscale(); ViewedImage = previewStages[index].ResultImage; ImageProcessor.CopyMat(ref Mat, ref previewStages[index].Mat); isColorised = previewStages[index].isColorised; GrayscaleImage = previewStages[index].GrayImage; ColorisedImage = previewStages[index].ColorisedImage; brightness = previewStages[index].brightness; contrast = previewStages[index].contrast; }