function [ DD, ind ] = ElimBound( m, D, ind )
% ElimBound eliminates redundant boundary wavelets to have a basis for the cut-off spline
% wavelet dictionary constructed with b=1
%
% Usage:    [ DD, ind ] = ElimBound( m, D, ind );
% 
% Inputs:
%   m       order of splines in dictionary (positive integer)
%   D       dictionary
%   ind     array of final indices for every scale in D (optional)
%           
% Outputs:
%   DD      basis, D without the redundant boundary wavelets 
%   ind     updated indices for DD
%
% For the construction of cut-off multiresolution-like wavelet dictionaries see BuildDIct.
%
% Note: The first scale is assumed to contain scaling functions thus the redundant
% wavelets are removed from all scales except the first one.
%
% If ind is not specified it considers only one scale (wavelets) and m-1 functions are
% removed from both sides.
%
% Comments: The support of semi-orthogonal spline wavelet of order m is given by
% supp=2*m-1. Thus the number of functions to eliminate at every scale at each border is 
% n=(supp-1)/2=m-1.
%
% References:
%   M. Andrle and L. Rebollo-Neira, "Spline wavelet dictionaries for non-linear signal
%   approximation", preprint, 2005.

% See http://www.ncrg.aston.ac.uk/Projects/BiOrthog/ for more details
n=m-1;
if nargin==2
    DD=D(:,n+1:end-n);
else  

s=length(ind);

%
DD=D(:,1:ind(1));
for i=1:s-1
    DD=[DD D(:,ind(i)+n+1:ind(i+1)-n)];
end  

for i=1:s-1
    ind(i+1)=ind(i+1)-i*2*n;
end    
end


%Copyright (C) 2006 Miroslav ANDRLE and Laura REBOLLO-NEIRA
%
%This program is free software; you can redistribute it and/or modify it under the terms 
%of the GNU General Public License as published by the Free Software Foundation; either 
%version 2 of the License, or (at your option) any later version.
%
%This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
%without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%See the GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License along with this program;
%if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
%Boston, MA  02110-1301, USA.
