예제 #1
0
        // Send this method a grayscale image, an int radius, and a double intensity
        // to blur the image with a Gaussian filter of that radius and intensity.
        public static int[,] BlurGreyscale(int[,] image, int length = 5, double intensity = 1)
        {
            (int width, int height) = (image.GetLength(0), image.GetLength(1));
            int[,] output           = new int[width - length, height - length];

            //Create Gaussian kernel
            double[,] kernel = initialiseKernel(length, intensity);

            //Convolve image with guassian kernel
            output = Convolver.Convolve(image, kernel);
            return(output);
        }
예제 #2
0
        public static (int[, ], Direction[, ]) IntensityGradient(int[,] image)
        {
            // Compute intensity
            // the derivatives Ix and Iy w.r.t. x and y are calculated. It can be
            // implemented by convolving I with Sobel kernels KERNEL_H and KERNEL_V
            int[,] horizontalIntensity = Convolver.Convolve(image, KERNEL_H); // Ix
            int[,] verticalIntensity   = Convolver.Convolve(image, KERNEL_V); // Iy

            // Compute magnitude G as  sqrt(Ix^2+Iy^2) and
            // direction: slope of the gradient as arctan(Iy/Ix) converted to degrees and then to compass directions.
            (int[,] gradient, Direction[,] direction) = magnitude(horizontalIntensity, verticalIntensity);
            return(gradient, direction);
        }