% M-Script to test the Gaussian Filter
%
% Authors: Borgo, Soranzo, Grassi
% Date: 2009

[MoonPic,Moonmap] = imread('moon.tif');
[Xax,Yax]=meshgrid([1:21],[1:21]);
StanDev=4;
FilterG = (1/sqrt(2*pi*StanDev)).*exp(-0.5*(((Xax-11)/StanDev).^2+...
((Yax-11)/StanDev).^2));
FilterG = FilterG/sum(sum(FilterG));

Filtered1=filter2(FilterG, MoonPic, 'same');

figure;
subplot(1,2,1)
image(MoonPic);
title('Original Image');
axis image;
subplot(1,2,2)
image(Filtered1);
title('Filtered Image');
axis image;
colormap(gray(255));
figure;
mesh(Xax,Yax,FilterG);
title('Filter Values');