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