I am trying to implement a gaussian filter with matlab.Here is my implementation: So far All I get as output is a black image. Any hints?
clear all;
close all;
I = double(imread('Put your path here'))/255;
I=rgb2gray(I);
sigma=1;
[M,N,s]=size(I);
f1=-fix(M/2):ceil(M/2)-1;
f2=-fix(N/2):ceil(N/2)-1;
[fx,fy]=meshgrid(f1,f2);
x=exp(-2*pi*pi*sigma*sigma*(fx/M.^2+fy/N.^2));
If=fft2(I);
If=fftshift(If);
If=If(:,:,1)*x;
If=ifftshift(If)
I=ifft2(If);
imshow(I)