% reduce - Gaussian convolves and downsamples an image.
% version 1
% Lance Williams 
% Dept. of Computer Science
% Univ. of New Mexico
%
function h=reduce(f)

rf=size(f,1);
cf=size(f,2);

g(1,:)=0.05*f(rf-1,:)+0.25*f(rf,:)+0.4*f(1,:)+0.25*f(2,:)+0.05*f(3,:);
i=2:rf/2-1;
g(i,:)=0.05*f(2*i-3,:)+0.25*f(2*i-2,:)+0.4*f(2*i-1,:)+0.25*f(2*i,:)+0.05*f(2*i+1,:);
g(rf/2,:)=0.05*f(rf-3,:)+0.25*f(rf-2,:)+0.4*f(rf-1,:)+0.25*f(rf,:)+0.05*f(1,:);

h(:,1)=0.05*g(:,cf-1)+0.25*g(:,cf)+0.4*g(:,1)+0.25*g(:,2)+0.05*g(:,3);
j=2:cf/2-1;
h(:,j)=0.05*g(:,2*j-3)+0.25*g(:,2*j-2)+0.4*g(:,2*j-1)+0.25*g(:,2*j)+0.05*g(:,2*j+1);
h(:,cf/2)=0.05*g(:,cf-3)+0.25*g(:,cf-2)+0.4*g(:,cf-1)+0.25*g(:,cf)+0.05*g(:,1);