%filtering and subsampling using various filters
%use filter4x4.m

function [g1,met]=switch_reduce(g0)

[C,R]=size(g0);

g1=[];
met=[];

%use only subsampling for edges of the image
for I=1:C/2
   g1(I,1)=g0(2*I,2);
   met(I,1)=0;
   g1(I,R/2)=g0(2*I,R);
   met(I,R/2)=0;
end
for J=2:R/2
   g1(1,J)=g0(2,2*J);
   met(1,J)=0;
   g1(C/2,J)=g0(C,2*J);
   met(C/2,J)=0;
end

%call filter4x4.m which is a 2D 4x4 filter
for I=2:C/2-1
   for J=2:R/2-1
      
      [g1(I,J),met(I,J)]=filter4x4(g0(2*I-2:2*I+1,2*J-2:2*J+1));
      
   end
end


