public GaussianFilter(int persentage = 100, int offset = 0) { progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); createGaussianKernel(3, 2); }
protected override Color calculateNewPixelColor(QBitmap sourceImage, int x, int y) { int ImgsW = sourceImage.Width; int ImgsH = sourceImage.Height; int Radius = 2; double _R_ = 0; double _G_ = 0; double _B_ = 0; double Z = 1.0 / Math.Pow(Radius, 4); for (int i = QM.clamp(x - Radius, 0, ImgsW); i < QM.clamp(x + Radius, 0, ImgsW); i++) { double _R = 0; double _G = 0; double _B = 0; for (int j = QM.clamp(y - Radius, 0, ImgsH); j < QM.clamp(y + Radius, 0, ImgsH); j++) { (byte R, byte G, byte B) = sourceImage.GetPixel(i, j); _R += R; _G += G; _B += B; } _R_ += _R * Z; _G_ += _G * Z; _B_ += _B * Z; } return(QM.Col(_R_, _G_, _B_)); }
protected override Color calculateNewPixelColor(QBitmap sourceImage, int x, int y) { int radiusX = kernel.GetLength(0) / 2; int radiusY = kernel.GetLength(1) / 2; double resultR = 0; double resultG = 0; double resultB = 0; for (int l = -radiusY; l <= radiusY; l++) { for (int k = -radiusX; k <= radiusX; k++) { // Значение по X int idX = QM.clamp(x + k, 0, sourceImage.Width - 1); // Значение по Y int idY = QM.clamp(y + l, 0, sourceImage.Height - 1); // Каналы в точки X,Y (byte R, byte G, byte B) = sourceImage.GetPixel(idX, idY); // kernel[0...radiusX, 0...radiusY] // Двумерная свертка resultR += R * kernel[k + radiusX, l + radiusY]; resultG += G * kernel[k + radiusX, l + radiusY]; resultB += B * kernel[k + radiusX, l + radiusY]; } } return(QM.Col(resultR, resultG, resultB)); }
public SubstractionFilter(QBitmap mask, int persentage = 100, int offset = 0) { maskImage = mask; progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); }
public SobelYFilter(int persentage = 100, int offset = 0) { progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); kernel = new float[size, size]; kernel[0, 0] = -1.0f; kernel[0, 1] = -2.0f; kernel[0, 2] = -1.0f; kernel[1, 0] = +0.0f; kernel[1, 1] = +0.0f; kernel[1, 1] = +0.0f; kernel[2, 0] = +1.0f; kernel[2, 1] = +2.0f; kernel[2, 2] = +1.0f; }
protected override Color calculateNewPixelColor(QBitmap sourceImage, int x, int y) { (byte oR, byte oG, byte oB) = maskImage.GetPixel(QM.clamp(x, 0, maskImage.Width), QM.clamp(y, 0, maskImage.Height)); (byte pR, byte pG, byte pB) = sourceImage.GetPixel(x, y); byte R = QM.clamp(oR - pR); byte G = QM.clamp(oG - pG); byte B = QM.clamp(oB - pB); return(QM.Col(R, G, B)); }
protected override Color calculateNewPixelColor(QBitmap sourceImage, int x, int y) { //Получаем значения трех каналов пикселя с координатами (x,y) (byte R, byte G, byte B) = sourceImage.GetPixel(x, y); R = QM.clamp(R * _R_); G = QM.clamp(G * _G_); B = QM.clamp(B * _B_); return(QM.Col(R, G, B)); }
protected override Color calculateNewPixelColor(QBitmap sourceImage, int x, int y) { byte k = 15; //Получаем значения трех каналов пикселя с координатами (x,y) (byte R, byte G, byte B) = sourceImage.GetPixel(x, y); double Intensity = (.299F * R + .587F * G + .113F * B); R = QM.clamp(Intensity + k * 2); G = QM.clamp(Intensity + k / 2); B = QM.clamp(Intensity - k * 1); return(QM.Col(R, G, B)); }
public BlurFilter(int persentage = 100, int offset = 0) { progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); int sizeX = 3; int sizeY = 3; kernel = new float[sizeX, sizeY]; for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { kernel[i, j] = 1.0f / (float)(sizeX * sizeY); } } }
public MedianaFilter(int persentage = 100, int offset = 0) { progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); }
public SobelFilter(int persentage = 100) { progressPerc = QM.clamp(persentage, 0, 100); }
public void SetPixel(int x, int y, double ch) { SetPixel(x, y, QM.clamp(ch)); }
public TopHat(int persentage = 100, int offset = 0) { progressPerc = QM.clamp(persentage, 0, 100); progressOffs = QM.clamp(offset, 0, 100 - progressPerc); }