public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { imageToProcess = base.apply(imageToProcess, reportProgressTo); for (int i = 0; i < imageToProcess.GetLength(0); i++) { int firstPixelY = -1; for (int j = 0; j < imageToProcess.GetLength(1); j++) { if (imageToProcess[i, j].ToArgb() == Color.Black.ToArgb()) if (firstPixelY <= 0 || firstPixelY + 1 == j) firstPixelY = j; else { for (int k = firstPixelY + 1; k < j; k++) imageToProcess[i, k] = Color.Black; firstPixelY = -1; } reportProgressTo.Progress++; } } return imageToProcess; }
public override int processPixel(int xCoordinate, int yCoordinate, Color[,] imageToProcess, MainViewModel reportProgressTo) { float sum = 0; int midX = (this.width - 1) / 2; int midY = (this.height - 1) / 2; // Loop over Weights for (int x = 0; x < this.width; x++) { int xOffset = x - midX; for (int y = 0; y < this.height; y++) { int yOffset = y - midY; // Need to double-check if the objects are black or white // Is image * weights bigger than 1 every coordinate? float result = imageToProcess[xCoordinate + xOffset, yCoordinate + yOffset].R * weights[x, y]; if (result > 1) { sum += 1; } // can be optimized by skipping the rest of the operations if one of the if-statements fails // just need to calculate and move the progressbar accordingly. reportProgressTo.Progress++; } } if (sum >= 9) // If the kernel fits in the object, the middle pixel needs to turn black { return 255; } else { return 0; } }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { if (decoratingKernel != null) { imageToProcess = decoratingKernel.apply(imageToProcess, reportProgressTo); } Color[,] endResultImage = new Color[imageToProcess.GetLength(0), imageToProcess.GetLength(1)]; Array.Copy(imageToProcess, endResultImage, imageToProcess.GetLength(0) * imageToProcess.GetLength(1)); int xOffset = (this.width - 1) / 2; int yOffset = (this.height - 1) / 2; for (int x = xOffset; x < imageToProcess.GetLength(0) - xOffset; x++) // GetLength(x), where x is the dimension, give you the length of the specified part of the array. { for (int y = yOffset; y < imageToProcess.GetLength(1) - yOffset; y++) { int sum = processPixel(x, y, imageToProcess, reportProgressTo); //sum = sum < 0 ? 0 : sum > 255 ? 255 : sum; endResultImage[x, y] = Color.FromArgb(sum, sum, sum); } } return endResultImage; }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { imageToProcess = base.apply(imageToProcess, reportProgressTo); Color[,] imageToReturn = new Color[imageToProcess.GetLength(0), imageToProcess.GetLength(1)]; Array.Copy(imageToProcess, imageToReturn, imageToProcess.GetLength(0) * imageToProcess.GetLength(1)); int xOffset = 1; int yOffset = 1; for (int x = xOffset; x < imageToProcess.GetLength(0) - xOffset; x++) { for (int y = yOffset; y < imageToProcess.GetLength(1) - yOffset; y++) { int highestValue = 0; foreach (BasicKernel kernel in kernels) { int kernelValue = kernel.processPixel(x, y, imageToProcess, reportProgressTo); kernelValue = kernelValue < 0 ? 0 : kernelValue > 255 ? 255 : kernelValue; if (highestValue < kernelValue) highestValue = kernelValue; } imageToReturn[x, y] = Color.FromArgb(highestValue, highestValue, highestValue); } } return imageToReturn; }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { DerivativeKernel xDerivative = new DerivativeKernel(null, DerivativeType.x); DerivativeKernel yDerivative = new DerivativeKernel(null, DerivativeType.y); return imageToProcess; }
public override int processPixel(int xCoordinate, int yCoordinate, Color[,] imageToProcess, MainViewModel reportProgressTo) { // https://en.wikipedia.org/wiki/Grayscale Color toConvert = imageToProcess[xCoordinate, yCoordinate]; // Y = 0.2162R + 0.7152G + 0.0722B // Kernel doorlopen? double y = toConvert.R * weightR + toConvert.G * weightG + toConvert.B * weightB; reportProgressTo.Progress++; return (int)Math.Floor(y); }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { imageToProcess = base.apply(imageToProcess, reportProgressTo); for (int x = 0; x < imageToProcess.GetLength(0); x++) { for (int y = 0; y < imageToProcess.GetLength(1); y++) { imageToProcess[x, y] = imageToProcess[x, y].R < this.thresholdValue ? Color.Black : Color.White; reportProgressTo.Progress++; } } return imageToProcess; }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { imageToProcess = base.apply(imageToProcess, reportProgressTo); for (int x = 0; x < imageToProcess.GetLength(0); x++) { for (int y = 0; y < imageToProcess.GetLength(1); y++) { imageToProcess[x,y] = InvertColor(imageToProcess[x, y]); reportProgressTo.Progress++; } } return imageToProcess; }
public override int processPixel(int xCoordinate, int yCoordinate, Color[,] imageToProcess, MainViewModel reportProgressTo) { float sum = 0; // Loop over Weights for (int x = 0; x < this.width; x++) { int xOffset = x - 1; for (int y = 0; y < this.height; y++) { int yOffset = y - 1; sum += imageToProcess[xCoordinate + xOffset, yCoordinate + yOffset].R * weights[x, y]; reportProgressTo.Progress++; } } return (int)Math.Floor(sum / 30) + 128; }
public override int processPixel(int xCoordinate, int yCoordinate, Color[,] imageToProcess, MainViewModel reportProgressTo) { float sum = 0; int midX = (this.width - 1) / 2; int midY = (this.height - 1) / 2; // Loop over Weights to calculate the convolution for (int x = 0; x < this.width; x++) { int xOffset = x - midX; for (int y = 0; y < this.height; y++) { int yOffset = y - midY; sum += imageToProcess[xCoordinate + xOffset, yCoordinate + yOffset].R * weights[x, y]; reportProgressTo.Progress++; } } return base.NormalizeColorSpace(sum); }
public override Color[,] apply(Color[,] imageToProcess, MainViewModel reportProgressTo) { imageToProcess = base.apply(imageToProcess, reportProgressTo); for (int i = 0; i < imageToProcess.GetLength(0); i++) { imageToProcess[i, 0] = Color.White; imageToProcess[i, imageToProcess.GetLength(1) - 1] = Color.White; reportProgressTo.Progress++; } for (int i = 0; i < imageToProcess.GetLength(1); i++) { imageToProcess[0, i] = Color.White; imageToProcess[imageToProcess.GetLength(0) - 1, i] = Color.White; reportProgressTo.Progress++; } return imageToProcess; }
public abstract int processPixel(int xCoordinate, int yCoordinate, Color[,] imageToProcess, MainViewModel reportProgressTo);