public static Bitmap LaplasjanFilter(Bitmap bitmap) { Bitmap b = (Bitmap)bitmap.Clone(); double[,] mask = MaskBox.GetLaplasjanMask(); for (int i = 1; i < bitmap.Width - 1; i++) { for (int j = 1; j < bitmap.Height - 1; j++) { double sigma = Convolution(GetArea(new Point(i, j), 3, bitmap), mask); byte byt = (byte)(sigma + 0.5); b.SetPixel(i, j, Color.FromArgb(byt, byt, byt)); } } return(b); }
public static Bitmap LowPassFilter(JMask name, Bitmap bitmap) { Bitmap b = (Bitmap)bitmap.Clone(); double[,] mask = MaskBox.GetMask(name); for (int i = 1; i < bitmap.Width - 1; i++) { for (int j = 1; j < bitmap.Height - 1; j++) { double sigma = Convolution(GetArea(new Point(i, j), 3, bitmap), mask) / (Math.Pow(mask.GetLength(0), 2)); byte byt = (byte)(sigma + 0.5); b.SetPixel(i, j, Color.FromArgb(byt, byt, byt)); } } return(b); }
public static Bitmap HighPassFilter(EMask name, Bitmap bitmap) { Bitmap b = (Bitmap)bitmap.Clone(); double[,] maskx = MaskBox.GetMaskX(name); double[,] masky = MaskBox.GetMaskY(name); for (int i = 1; i < bitmap.Width - 1; i++) { for (int j = 1; j < bitmap.Height - 1; j++) { double sigma = Math.Sqrt(Math.Pow(Convolution(GetArea(new Point(i, j), 3, bitmap), maskx), 2) + Math.Pow(Convolution(GetArea(new Point(i, j), 3, bitmap), masky), 2)); byte byt = (byte)(sigma + 0.5); b.SetPixel(i, j, Color.FromArgb(byt, byt, byt)); } } return(b); }