Difference of Gaussians filter.

In imaging science, the difference of Gaussians is a feature enhancement algorithm that involves the subtraction of one blurred version of an original image from another, less blurred version of the original.

In the simple case of grayscale images, the blurred images are obtained by convolving the original grayscale images with Gaussian kernels having differing standard deviations. Blurring an image using a Gaussian kernel suppresses only high-frequency spatial information. Subtracting one image from the other preserves spatial information that lies between the range of frequencies that are preserved in the two blurred images. Thus, the difference of Gaussians is a band-pass filter that discards all but a handful of spatial frequencies that are present in the original grayscale image.

This filter implementation has been contributed by Diego Catalano.

References: Wikipedia contributors. "Difference of Gaussians." Wikipedia, The Free Encyclopedia. Wikipedia, The Free Encyclopedia, 1 Jun. 2013. Web. 10 Feb. 2014.

Inheritance: BaseInPlaceFilter
        public void ProcessImageTest()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;
            new MatrixToImage().Convert(diag, out input);

            DifferenceOfGaussians gabor = new DifferenceOfGaussians();

            // Apply the filter
            Bitmap output = gabor.Apply(input);

            double[,] actual; 
            
            new ImageToMatrix().Convert(output, out actual);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected = 
            {
                { 0.00784313725490196, 0.0274509803921569, 0, 0, 0.00392156862745098 },
                { 0.0196078431372549, 0, 0, 0.00392156862745098, 0.00392156862745098 },
                { 0, 0, 0, 0.0156862745098039, 0.0156862745098039 },
                { 0, 0, 0.0156862745098039, 0.0117647058823529, 0 },
                { 0, 0.00784313725490196, 0.0196078431372549, 0, 0 } 
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }
        public void ApplyTest1()
        {
            Bitmap image = Properties.Resources.lena512;

            var dog = new DifferenceOfGaussians();
            
            Bitmap result = dog.Apply(image);

            // ImageBox.Show(result);
            Assert.IsNotNull(result);
        }