Gabor filter.

In image processing, a Gabor filter, named after Dennis Gabor, is a linear filter used for edge detection. Frequency and orientation representations of Gabor filters are similar to those of the human visual system, and they have been found to be particularly appropriate for texture representation and discrimination. In the spatial domain, a 2D Gabor filter is a Gaussian kernel function modulated by a sinusoidal plane wave. The Gabor filters are self-similar: all filters can be generated from one mother wavelet by dilation and rotation.

Inheritance: BaseFilter
Beispiel #1
0
        public void ProcessImageTest()
        {
            double[,] diag = Matrix.Magic(5);

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

            // Create a new Gabor filter
            GaborFilter gabor = new GaborFilter();

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

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

            double[,] expected = 
            {
                { 0.192156862745098, 0.176470588235294, 0.254901960784314, 0.396078431372549, 0.529411764705882 },
                { 0.16078431372549, 0.305882352941176, 0.494117647058824, 0.635294117647059, 0.654901960784314 },
                { 0.407843137254902, 0.623529411764706, 0.737254901960784, 0.701960784313725, 0.564705882352941 },
                { 0.752941176470588, 0.815686274509804, 0.713725490196078, 0.541176470588235, 0.403921568627451 },
                { 0.847058823529412, 0.694117647058824, 0.505882352941176, 0.380392156862745, 0.329411764705882 } 
            };

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

            GaborFilter gabor = new GaborFilter();
            
            Bitmap result = gabor.Apply(image);

            // ImageBox.Show(result);
            Assert.IsNotNull(result);
        }
Beispiel #3
0
        private void SetFilter()
        {
            ImageType = ImageTypes.Rgb24bpp;
            Af.GaborFilter newFilter = new Af.GaborFilter();
            newFilter.Theta  = angle;
            newFilter.Size   = size;
            newFilter.Gamma  = gamma;
            newFilter.Lambda = lambda;
            newFilter.Psi    = psi;
            newFilter.Sigma  = sigma;

            imageFilter = newFilter;
        }
 /// <summary>
 /// <para>(Accord .NET internal call)</para>
 /// In image processing, a Gabor filter, named after Dennis Gabor, is a linear 
 /// filter used for edge detection. Frequency and orientation representations 
 /// of Gabor filters are similar to those of the human visual system, and they
 /// have been found to be particularly appropriate for texture representation 
 /// and discrimination. In the spatial domain, a 2D Gabor filter is a Gaussian
 /// kernel function modulated by a sinusoidal plane wave. The Gabor filters are
 /// self-similar: all filters can be generated from one mother wavelet by dilation
 /// and rotation.
 /// </summary>
 /// <param name="img">Image.</param>
 /// <param name="size">The size of the filter</param>
 /// <param name="sigma">The Gaussian variance for the filter.</param>
 /// <param name="theta">The orientation for the filter, in radians.</param>
 /// <param name="lambda">The wavelength for the filter.</param>
 /// <param name="gamma">The aspect ratio for the filter.</param>
 /// <param name="psi">The phase offset for the filter.</param>
 /// <returns>Filtered image.</returns>
 public static Gray<byte>[,] GaborFilter(this Gray<byte>[,] img, int size = 3, double sigma = 2, double theta = 0.6, double lambda = 4.0, double gamma = 0.3, double psi = 1.0)
 { 
     GaborFilter gf = new GaborFilter
     {
         Size = size,
         Sigma = sigma,
         Theta = theta,
         Lambda = lambda,
         Gamma = gamma,
         Psi = psi
     };
     
     return GaborFilter(img, gf);
 }
 /// <summary>
 /// <para>(Accord .NET internal call)</para>
 /// In image processing, a Gabor filter, named after Dennis Gabor, is a linear 
 /// filter used for edge detection. Frequency and orientation representations 
 /// of Gabor filters are similar to those of the human visual system, and they
 /// have been found to be particularly appropriate for texture representation 
 /// and discrimination. In the spatial domain, a 2D Gabor filter is a Gaussian
 /// kernel function modulated by a sinusoidal plane wave. The Gabor filters are
 /// self-similar: all filters can be generated from one mother wavelet by dilation
 /// and rotation.
 /// </summary>
 /// <param name="img">Image.</param>
 /// <param name="gaborFilter">Gabor filter instance. 
 /// <para>To avoid calculating Gabor every time use this function overload that receives instance.</para>
 /// </param>
 /// <returns>Filtered image.</returns>
 internal static Gray<byte>[,] GaborFilter(this Gray<byte>[,] img, GaborFilter gaborFilter)
 {
     return img.ApplyFilter(gaborFilter);
 }