function [im, L]  =  prefilter(im0, alpha, tau, filterID)
%
% projects the image onto the four different approximation spaces used in
% the construction.
% alpha = degree of fractionlal B-spline, tau = shift.
% filterID = tag for the four approximation spaces.
%
M                         = length(im0);
im_projected              = zeros(M + 1,M + 1);
im_projected(1 : M,1 : M) = im0;
im_projected(1 : M,M + 1) = im0( : ,M);
im_projected(M+1  ,1 : M) = im0(M, : );
im_projected(M+1  ,M+1)   = im0(M,M);

[P1, P2]  =  projectionFilters(M + 1, alpha, tau);

switch  filterID
    
        
    case  1

    for i = 1 : M+1
         f                   = im_projected(i, : );
         im_projected(i, : ) = ifft( P1.*fft(f) );
    end

    for i= 1 : M+1
           f = im_projected(:,i);
           F = fft(f).';
           im_projected( : ,i) = ifft( P1.*F ).';
    end


    
    case 2

    for i = 1 : M+1
        f=im_projected(i,:);
        im_projected(i,:)=ifft(P2.*fft(f));
    end


    for i = 1 : M+1
        f = im_projected(:,i);
        F = fft(f).';
        im_projected( : ,i) = ifft( P2.*F ).';
    end
    
    

    case 3 

    for i = 1 : M+1
        f = im_projected(i, : );
        im_projected(i, : ) = ifft( P1.*fft(f) );
    end

    for i = 1 : M+1
        f = im_projected(:,i);
        F = fft(f).';
        im_projected( : ,i) = ifft(P2.*F).';
    end


    case 4

    for i = 1 : M+1
        f = im_projected(i, : );
        im_projected(i, : ) = ifft( P2.*fft(f) );
    end

    for i = 1 : M+1
        f = im_projected( : ,i);
        F = fft(f).';
        im_projected( : ,i) = ifft( P1.*F ).';
    end

end
    
 im  = real( im_projected(1 : M,1 : M) );
 L = [ im_projected( : ,M + 1)'  im_projected(M + 1,1 : M)];


