/// <summary> /// blur the image /// </summary> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight of effect</param> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.Blur(ref Img, 30.0); /// ]]> /// </code> /// </example> /// <see cref="blur"/> /// <returns></returns> static public void Blur(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[1, 1] = weight; CMatrix.Factor = weight + 8; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// remove mean of image /// </summary> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight of effect</param> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.RemoveMean(ref Img, 10.0); /// ]]> /// </code> /// </example> /// <returns></returns> static public void RemoveMean(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = -1; CMatrix.Matrix[1, 0] = -1; CMatrix.Matrix[2, 0] = -1; CMatrix.Matrix[0, 1] = -1; CMatrix.Matrix[1, 1] = weight; CMatrix.Matrix[2, 1] = -1; CMatrix.Matrix[0, 2] = -1; CMatrix.Matrix[1, 2] = -1; CMatrix.Matrix[2, 2] = -1; CMatrix.Factor = weight - 8; ApplyConvolution3x3(ref Img, CMatrix); }
// Sharpen image public static Bitmap SharpenImage(Bitmap image, double weight) { var matrix = new ConvolutionMatrix(3); matrix.SetAll(1); matrix.Matrix[0, 0] = 0; matrix.Matrix[1, 0] = -2; matrix.Matrix[2, 0] = 0; matrix.Matrix[0, 1] = -2; matrix.Matrix[1, 1] = weight; matrix.Matrix[2, 1] = -2; matrix.Matrix[0, 2] = 0; matrix.Matrix[1, 2] = -2; matrix.Matrix[2, 2] = 0; matrix.Factor = weight - 8; return(Convolution3x3(image, matrix)); }
/// <summary> /// apply gaussianblur to image /// </summary> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.GaussianBlur(ref Img, 20.0); /// ]]> /// </code> /// </example> /// <param name="Img">image to manipulate</param> /// <param name="peakValue">parameter</param> /// <see cref="gaussian"/> /// <returns></returns> static public void GaussianBlur(ref ImageData Img, double peakValue) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = peakValue / 4; CMatrix.Matrix[1, 0] = peakValue / 2; CMatrix.Matrix[2, 0] = peakValue / 4; CMatrix.Matrix[0, 1] = peakValue / 2; CMatrix.Matrix[1, 1] = peakValue; CMatrix.Matrix[2, 1] = peakValue / 2; CMatrix.Matrix[0, 2] = peakValue / 4; CMatrix.Matrix[1, 2] = peakValue / 2; CMatrix.Matrix[2, 2] = peakValue / 4; CMatrix.Factor = peakValue * 4; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// apply emboss effect on image /// </summary> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight of emboss effect</param> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.Emboss(ref Img, 4.0); /// ]]> /// </code> /// </example> /// <see cref="emboss"/> /// <returns></returns> static public void Emboss(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = -1; CMatrix.Matrix[1, 0] = 0; CMatrix.Matrix[2, 0] = -1; CMatrix.Matrix[0, 1] = 0; CMatrix.Matrix[1, 1] = weight; CMatrix.Matrix[2, 1] = 0; CMatrix.Matrix[0, 2] = -1; CMatrix.Matrix[1, 2] = 0; CMatrix.Matrix[2, 2] = -1; CMatrix.Factor = 4; CMatrix.Offset = 127; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// blur the image /// </summary> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight of effect</param> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.Blur(ref Img, 30.0); /// ]]> /// </code> /// </example> /// <see cref="blur"/> /// <returns></returns> public static void Blur(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[1, 1] = weight; CMatrix.Factor = weight + 8; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// sharpen an image /// </summary> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.Sharpen(ref Img, 4.0); /// ]]> /// </code> /// </example> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight</param> /// <see cref="sharpen"/> /// <returns></returns> public static void Sharpen(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = 0; CMatrix.Matrix[1, 0] = -2; CMatrix.Matrix[2, 0] = 0; CMatrix.Matrix[0, 1] = -2; CMatrix.Matrix[1, 1] = weight; CMatrix.Matrix[2, 1] = -2; CMatrix.Matrix[0, 2] = 0; CMatrix.Matrix[1, 2] = -2; CMatrix.Matrix[2, 2] = 0; CMatrix.Factor = weight - 8; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// apply gaussianblur to image /// </summary> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.GaussianBlur(ref Img, 20.0); /// ]]> /// </code> /// </example> /// <param name="Img">image to manipulate</param> /// <param name="peakValue">parameter</param> /// <see cref="gaussian"/> /// <returns></returns> public static void GaussianBlur(ref ImageData Img, double peakValue) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = peakValue / 4; CMatrix.Matrix[1, 0] = peakValue / 2; CMatrix.Matrix[2, 0] = peakValue / 4; CMatrix.Matrix[0, 1] = peakValue / 2; CMatrix.Matrix[1, 1] = peakValue; CMatrix.Matrix[2, 1] = peakValue / 2; CMatrix.Matrix[0, 2] = peakValue / 4; CMatrix.Matrix[1, 2] = peakValue / 2; CMatrix.Matrix[2, 2] = peakValue / 4; CMatrix.Factor = peakValue * 4; ApplyConvolution3x3(ref Img, CMatrix); }
/// <summary> /// apply emboss effect on image /// </summary> /// <param name="Img">image to manipulate</param> /// <param name="weight">weight of emboss effect</param> /// <example> /// <code> /// <![CDATA[ /// ImageData Img = new ImageData(...); /// // apply filter to image /// Filter.Emboss(ref Img, 4.0); /// ]]> /// </code> /// </example> /// <see cref="emboss"/> /// <returns></returns> public static void Emboss(ref ImageData Img, double weight) { ConvolutionMatrix CMatrix = new ConvolutionMatrix(3); CMatrix.SetAll(1); CMatrix.Matrix[0, 0] = -1; CMatrix.Matrix[1, 0] = 0; CMatrix.Matrix[2, 0] = -1; CMatrix.Matrix[0, 1] = 0; CMatrix.Matrix[1, 1] = weight; CMatrix.Matrix[2, 1] = 0; CMatrix.Matrix[0, 2] = -1; CMatrix.Matrix[1, 2] = 0; CMatrix.Matrix[2, 2] = -1; CMatrix.Factor = 4; CMatrix.Offset = 127; ApplyConvolution3x3(ref Img, CMatrix); }