% This bit of code demonstrates how to get a 2-dimensional
% Gaussian-shaped filter out of the fspecial function, how to use
% the subplot function, and how to display the filter as either a
% regular image or a surface, using the surf function. 
%
% It also shows that filtering a Gaussian filter with itself
% produces a filter that is the same as another Gaussian filter
% with a variance that is twice as large in each direction as the
% variance of the original filter. 

figure(4);

gfilter=fspecial('gaussian',[15 15], 1);

subplot(2,3,1);
imagesc(gfilter);
colormap(jet);

subplot(2,3,4);
surf(gfilter);

gfilter2=fspecial('gaussian',[15 15],sqrt(2));
subplot(2,3,2);
imagesc(gfilter2);

subplot(2,3,5);
surf(gfilter2);

gfilter_alt=filter2(gfilter,gfilter);
subplot(2,3,3);
imagesc(gfilter_alt);
subplot(2,3,6);
surf(gfilter_alt);
