Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        // 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));
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <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);
 }
Ejemplo n.º 8
0
 /// <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);
 }
Ejemplo n.º 9
0
 /// <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);
 }