I'm having trouble applying a Gaussian filter to an Image and one of the requirements is to make sure it's a circularly symmetric filter. I am not sure if I need to add a zero-padding sequence but please take a look at my code below and let me know if you can help me out at all! Thank you!
Please Note: I am not able to use any toolbox functions otherwise this would be pretty simple and straightforward.
L=256;
L1 = 255;
%load 'iptest_im.mat'
%ipFreq(iptest01)
[ImageX,ImageY] = size(A);
load 'iptest_im.mat';
A = iptest01;
A=double(A); % Just in Case
Fourier=fft2(A);
ABS_Fourier=abs(Fourier);
%Gaussian
Gaussian=zeros(ImageX,ImageY);
sigma=5; % Sigma Values for Gaussian Filter **** WHERE YOU CHANGE
for i = 1:ImageX
for j = 1:ImageY
D = (i-ImageX/2)^2 + (j-ImageY/2)^2;
Gaussian(i,j) = L1*exp(-(D)/(2*(sigma)^2));
end
end
GaussianFilt = fft2(Gaussian);
FourierFilt = Fourier .* GaussianFilt;
%Display for No shift
FFT_NoShift = abs((log10(FourierFilt+1)));
minA=min(min(FFT_NoShift));
FFT_NoShift = FFT_NoShift-minA; % shift
maxA = max(max(FFT_NoShift));
if maxA~=0
FFT_NoShift=FFT_NoShift*L1/maxA; % compress or expand
end
%Display for Shift
FFT_Shifted = fftshift(abs(log10(FourierFilt+1)));
minA=min(min(FFT_Shifted));
FFT_Shifted = FFT_Shifted-minA; % shift
maxA = max(max(FFT_Shifted));
if maxA~=0
FFT_Shifted=FFT_Shifted*L1/maxA; % compress or expand
end
InvFFT = abs(ifft2(FourierFilt));
%InvFFT = abs(ifft2(FFT_Shifted1));
%InvFFT = abs(ifft2(FFT_NoShift1));
imshow()
. – MichaelTr7