% 2-d gaussian lowpass filter using the DFT
clear
x=[1 -1 3 2;
   2 1 2 4;
   1 -1 2 -2;
   3 1 2 2]; % input
h=[0.787 0.1065 0 0 0 0 0 0.1065]; % decomposed filter coefficients
x = padarray(x,[1 1],'replicate') % replicated
H=fft(h); % dft of filter
X=fft2(x,8,8); % dft of input
%
Y=zeros(8);
for k=1:8
  Y(1:8,k)=X(1:8,k) .* H'; % column filtering
end
for k=1:8
  Y(k,1:8)=Y(k,1:8) .* H; % row filtering
end
%
y=real(ifft2(Y)); % idft is the output
y(2:5,2:5)
 


 
 

