% This bit of code shows how to build an image pyramid from an
% image by filtering it over and over with a Gaussian filter
% obtained from the fspecial function. 
%
% It plots the successive images of the image pyradmid 
% in different subwindows. 

im=imread('../Images/flower.tiff');
imagesc(im);

figure(3);
subplot(2,3,1);
img=double(rgb2gray(im));
imagesc(img);
colormap(gray);

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

blur1=filter2(gfilter,img);
subplot(2,3,2);
imagesc(blur1);

blur2=filter2(gfilter,blur1);
subplot(2,3,3);
imagesc(blur2);

blur3=filter2(gfilter,blur2);
subplot(2,3,4);
imagesc(blur3);

blur4=filter2(gfilter,blur3);
subplot(2,3,5);
imagesc(blur4);

blur5=filter2(gfilter,blur4);
subplot(2,3,6);
imagesc(blur5);

