예제 #1
0
        /// <summary>
        /// Run a blur matrix over the values
        /// </summary>
        /// <param name="values">Values to be blurred</param>
        /// <returns>Array containing the blurred values</returns>
        public static byte[,] BlurValues(byte[,] values)
        {
            ConvolutionMatrix matrix = new ConvolutionMatrix(
                1, 2, 1,
                2, 4, 2,
                1, 2, 1);

            matrix.Factor = 16;

            return(ConvolutionMatrix.Apply(values, matrix));
        }
예제 #2
0
        /// <summary>
        /// Run a sharpening matrix over the values
        /// </summary>
        /// <param name="values">Values to be sharpened</param>
        /// <returns>Array containing the sharpened values</returns>
        public static byte[,] SharpenValues(byte[,] values)
        {
            // sharpen
            ConvolutionMatrix matrix = new ConvolutionMatrix(
                0, -2, 0,
                -2, 11, -2,
                0, -2, 0);

            matrix.Factor = 3;

            return(ConvolutionMatrix.Apply(values, matrix));
        }
예제 #3
0
        //ApplySmooth(ref b, 1);
        public static void ApplySmooth(ref Bitmap bmp, int weight)
        {
            ConvolutionMatrix m = new ConvolutionMatrix();

            m.Apply(1);
            m.Pixel  = weight;
            m.Factor = weight + 8;

            Convolution C = new Convolution();

            C.Matrix = m;
            C.Convolution3x3(ref bmp);
        }
예제 #4
0
        //ApplyMeanRemoval(ref b, 9);
        public static void ApplyMeanRemoval(ref Bitmap bmp, int weight)
        {
            ConvolutionMatrix m = new ConvolutionMatrix();

            m.Apply(-1);
            m.Pixel  = weight;
            m.Factor = weight - 8;

            Convolution C = new Convolution();

            C.Matrix = m;
            C.Convolution3x3(ref bmp);
        }
예제 #5
0
        //ApplySharpen(ref b, 11);
        public static void ApplySharpen(ref Bitmap bmp, int weight)
        {
            ConvolutionMatrix m = new ConvolutionMatrix();

            m.Apply(0);
            m.Pixel  = weight;
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = -2;
            m.Factor = weight - 8;

            Convolution C = new Convolution();

            C.Matrix = m;
            C.Convolution3x3(ref bmp);
        }
예제 #6
0
        //ApplyGaussianBlur(ref b, 4);
        public static void ApplyGaussianBlur(ref Bitmap bmp, int Weight)
        {
            ConvolutionMatrix m = new ConvolutionMatrix();

            m.Apply(1);
            m.Pixel  = Weight;
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 2;
            m.Factor = Weight + 12;

            Convolution C = new Convolution();

            C.Matrix = m;
            C.Convolution3x3(ref bmp);
        }
예제 #7
0
        //Bitmap b = (Bitmap)Image.FromFile("rose.jpg");
        //ApplyEmbossLaplacian(ref b);
        public static void ApplyEmbossLaplacian(ref Bitmap bmp)
        {
            ConvolutionMatrix m = new ConvolutionMatrix();

            m.Apply(-1);
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 0;
            m.Pixel  = 4;
            m.Offset = 127;

            Convolution C = new Convolution();

            C.Matrix = m;
            C.Convolution3x3(ref bmp);
        }
예제 #8
0
 public override Image Apply(Image img)
 {
     using (img)
     {
         ConvolutionMatrix cm = new ConvolutionMatrix();
         cm[0, 0]  = X0Y0 / Factor;
         cm[0, 1]  = X1Y0 / Factor;
         cm[0, 2]  = X2Y0 / Factor;
         cm[1, 0]  = X0Y1 / Factor;
         cm[1, 1]  = X1Y1 / Factor;
         cm[1, 2]  = X2Y1 / Factor;
         cm[2, 0]  = X0Y2 / Factor;
         cm[2, 1]  = X1Y2 / Factor;
         cm[2, 2]  = X2Y2 / Factor;
         cm.Offset = Offset;
         return(cm.Apply(img));
     }
 }
예제 #9
0
 public override Bitmap Apply(Bitmap bmp)
 {
     using (bmp)
     {
         ConvolutionMatrix cm = new ConvolutionMatrix();
         cm[0, 0]  = X0Y0 / Factor;
         cm[0, 1]  = X1Y0 / Factor;
         cm[0, 2]  = X2Y0 / Factor;
         cm[1, 0]  = X0Y1 / Factor;
         cm[1, 1]  = X1Y1 / Factor;
         cm[1, 2]  = X2Y1 / Factor;
         cm[2, 0]  = X0Y2 / Factor;
         cm[2, 1]  = X1Y2 / Factor;
         cm[2, 2]  = X2Y2 / Factor;
         cm.Offset = Offset;
         return(cm.Apply(bmp));
     }
 }