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

Community Treasure Hunt

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

Start Hunting!

Translated by