protected override unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { var(A, R, G, B) = RGB.GetBytesARGB(); int radius = Radius; int square = (radius * 2 + 1) * (radius * 2 + 1); int sumR = 0, sumG = 0, sumB = 0, sumA = 0; for (int iy = -radius; iy <= radius; iy++) { for (int ix = -radius; ix <= radius; ix++) { byte *pixel = refPixel(ix + x, iy + y, true); sumR += pixel[R]; sumG += pixel[G]; sumB += pixel[B]; sumA += pixel[A]; } } sumR /= square; sumG /= square; sumB /= square; sumA /= square; result[x, y, A] = (byte)sumA; result[x, y, R] = (byte)sumR; result[x, y, G] = (byte)sumG; result[x, y, B] = (byte)sumB; }
protected override unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { var(A, R, G, B) = RGB.GetBytesARGB(); byte *pixel = refPixel(x, y, false); result[x, y, A] = pixel[A]; result[x, y, R] = pixel[R]; result[x, y, G] = pixel[G]; result[x, y, B] = pixel[B]; }
protected override unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { var(A, R, G, B) = RGB.GetBytesARGB(); byte *pixel = refPixel(x, y, false); result[x, y, A] = pixel[A]; byte *Rpixel = refPixel(x + 1, y); byte Rdist = (byte)math_dist(pixel[R], pixel[G], pixel[B], Rpixel[R], Rpixel[G], Rpixel[B]); byte *Lpixel = refPixel(x - 1, y); byte Ldist = (byte)math_dist(pixel[R], pixel[G], pixel[B], Lpixel[R], Lpixel[G], Lpixel[B]); byte *Dpixel = refPixel(x, y + 1); byte Ddist = (byte)math_dist(pixel[R], pixel[G], pixel[B], Dpixel[R], Dpixel[G], Dpixel[B]); byte *Upixel = refPixel(x, y - 1); byte Udist = (byte)math_dist(pixel[R], pixel[G], pixel[B], Upixel[R], Upixel[G], Upixel[B]); result[x, y, R] = result[x, y, G] = result[x, y, B] = (byte)(255 - math_mix(Rdist, Ldist, Ddist, Udist)); }
protected override unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { var(A, R, G, B) = RGB.GetBytesARGB(); byte *pixel = refPixel(x, y, false); result[x, y, A] = pixel[A]; byte distance(byte R1, byte G1, byte B1, byte R2, byte G2, byte B2) // оптимизировать через модули вместо квадратов и корней { return((byte)System.Math.Sqrt((R1 - R2) * (R1 - R2) + (G1 - G2) * (G1 - G2) + (B1 - B2) * (B1 - B2))); } byte *npixel = refPixel(x + 1, y); byte dist = distance(pixel[R], pixel[G], pixel[B], npixel[R], npixel[G], npixel[B]); dist = (byte)(dist > 32 ? 255 : 0); result[x, y, R] = result[x, y, G] = result[x, y, B] = dist; }
protected override unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { var(A, R, G, B) = RGB.GetBytesARGB(); int radius = Radius; int sumR = 0, sumG = 0, sumB = 0, sumA = 0; byte *pixel = refPixel(x - radius, y, true); sumR += pixel[R]; sumG += pixel[G]; sumB += pixel[B]; sumA += pixel[A]; pixel = refPixel(x + radius, y, true); sumR += pixel[R]; sumG += pixel[G]; sumB += pixel[B]; sumA += pixel[A]; pixel = refPixel(x, y - radius, true); sumR += pixel[R]; sumG += pixel[G]; sumB += pixel[B]; sumA += pixel[A]; pixel = refPixel(x, y + radius, true); sumR += pixel[R]; sumG += pixel[G]; sumB += pixel[B]; sumA += pixel[A]; sumR /= 4; sumG /= 4; sumB /= 4; sumA /= 4; result[x, y, A] = (byte)sumA; result[x, y, R] = (byte)sumR; result[x, y, G] = (byte)sumG; result[x, y, B] = (byte)sumB; }
protected virtual unsafe void Technique(int x, int y, ref byte[,,] result, RefPixelDelegate refPixel) { }