Apply 2D Gabor wavelet in Images

2 次查看(过去 30 天)
Khawaja Asim
Khawaja Asim 2014-8-10
回答: Naga 2024-9-27
Hi I want to apply 2D Gabor filter on images at four orientations (0, 45, 90, 135 degrees). The output for every pixel should be like a vector [m0 m45 m90 m135], where m is the magnitude of orientation at that angle. Can anyone help me with the code?

回答(1 个)

Naga
Naga 2024-9-27
Hello Asim,
Below is a sample code to apply 2D Gabor filters to an image at four orientations (0, 45, 90, and 135 degrees) and store the magnitudes in a vector for each pixel.
I = imread('sample.jpg');
I = rgb2gray(I);
% Define Gabor filter parameters
wavelength = 4;
orientationAngles = [0, 45, 90, 135];
bandwidth = 1;
[m, n] = size(I);
magnitudeMatrix = zeros(m, n, numel(orientationAngles));
% Apply Gabor filter at each orientation
for i = 1:numel(orientationAngles)
gaborFilter = gabor(wavelength, orientationAngles(i), ...
'SpatialFrequencyBandwidth', bandwidth);
magnitudeMatrix(:,:,i) = imgaborfilt(I, gaborFilter);
end
for i = 1:numel(orientationAngles)
subplot(2, 2, i);
imshow(magnitudeMatrix(:,:,i), []);
title(['Orientation: ', num2str(orientationAngles(i)), '°']);
end

类别

Help CenterFile Exchange 中查找有关 Denoising and Compression 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by