Create Gabor filter or Gabor filter bank
a Gabor filter with the specified
g = gabor(
orientation (in degrees). If
gabor returns an array of
called a filter bank, that contain all the
unique combinations of
For example, if
wavelength is a vector of length
orientation is a vector of length 3, then
the output array
g is a vector of length 6. To
apply the Gabor filters to an image, use the
Create a sample image of a checkerboard.
A = checkerboard(20);
Create an array of Gabor filters.
wavelength = 20; orientation = [0 45 90 135]; g = gabor(wavelength,orientation);
Apply the filters to the checkerboard image.
outMag = imgaborfilt(A,g);
Display the results.
outSize = size(outMag); outMag = reshape(outMag,[outSize(1:2),1,outSize(3)]); figure, montage(outMag,'DisplayRange',); title('Montage of gabor magnitude output images.');
Create array of Gabor filters.
g = gabor([5 10],[0 90]);
Visualize the real part of the spatial convolution kernel of each Gabor filter in the array.
figure; subplot(2,2,1) for p = 1:length(g) subplot(2,2,p); imshow(real(g(p).SpatialKernel),); lambda = g(p).Wavelength; theta = g(p).Orientation; title(sprintf('Re[h(x,y)], \\lambda = %d, \\theta = %d',lambda,theta)); end
wavelength— Wavelength of sinusoid
Wavelength of sinusoid, specified as a numeric scalar or vector, in pixels/cycle.
orientation— Orientation of filter in degrees
Orientation of filter in degrees, specified as a numeric scalar
in the range
[0 180], where the orientation is
defined as the normal direction to the sinusoidal plane wave.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
g = gabor(4,90,'SpatialFrequencyBandwidth',1.5);
'SpatialFrequencyBandwidth'— Define spatial-frequency bandwidth
A numeric vector that defines the spatial-frequency bandwidth in units of Octaves. The spatial-frequency bandwidth determines the cutoff of the filter response as frequency content in the input image varies from the preferred frequency, 1/lambda. Typical values for spatial-frequency bandwidth are in the range [0.5 2.5].
'SpatialAspectRatio'— Aspect ratio of Gaussian in spatial domain
Aspect ratio of Gaussian in spatial domain, specified as a numeric
vector that defines the ratio of the semi-major and semi-minor axes
of the Gaussian envelope:
This parameter controls the ellipticity of the Gaussian envelope.
Typical values for spatial aspect ratio are in the range
g— Gabor filter array
Gabor filter array, returned as an array of