dwtlevel1

PURPOSE ^

dwtlevel1.m

SYNOPSIS ^

function w = dwtlevel1(x, h0, h1, sym)

DESCRIPTION ^

 dwtlevel1.m

 One level of the discrete wavelet transform.  Periodic extension (for now)
 and the wavelets are lined up the best way for "tree structure".
 Usage : w = dwtlevel1(x, h0, h1, sym)

 Written by : Justin Romberg
 Created : 5/1/2001

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % dwtlevel1.m
0002 %
0003 % One level of the discrete wavelet transform.  Periodic extension (for now)
0004 % and the wavelets are lined up the best way for "tree structure".
0005 % Usage : w = dwtlevel1(x, h0, h1, sym)
0006 %
0007 % Written by : Justin Romberg
0008 % Created : 5/1/2001
0009 
0010 function w = dwtlevel1(x, h0, h1, sym)
0011 
0012 if (nargin == 3), sym=0; end
0013 
0014 N = length(x);
0015 m0 = length(h0);
0016 m1 = length(h1);
0017 
0018 if (m0 ~= m1)
0019   error('Use biorfilt to create filters');
0020 end
0021 
0022 % NEED TO FIX THIS SO IT WORKS LIKE BIORFILT()
0023 % if wavelet filters have unequal length, zero pad the shorter one
0024 % the difference in length has to be even
0025 %if (m0 > m1)
0026 %  h1 = [zeros(1,(m0-m1)/2) h1 zeros(1,(m0-m1)/2)];
0027 %  m1 = length(h1);
0028 %elseif (m1 > m0)
0029 %  h0 = [zeros(1,(m1-m0)/2) h0 zeros(1,(m1-m0)/2)];
0030 %  m0 = length(h0);
0031 %end
0032 
0033 % center on the middle of the filter
0034 % odd length - hole at (m1-1)/2
0035 %    (bottom left node of tree centers on sample 1.5)
0036 % even length - hole at m1/2
0037 %    (bottom left node of tree centers on sample 1)
0038 k = floor(m1/2);
0039 if (sym == 0)
0040   % circular filtering
0041   c0 = cconv(x, h0, k);
0042   c1 = cconv(x, h1, k);
0043   % downsample
0044   w = [c0(1:2:N) c1(1:2:N)];
0045 elseif (sym == 1)
0046   k = floor(m1/2)-1;
0047   % symmetrically extend
0048   xe = symext(x, k, m0-k-1, 'o', 's');
0049   % filter
0050   c0 = conv2(xe, h0, 'valid');
0051   c1 = conv2(xe, h1, 'valid');
0052   % downsample
0053   w = [c0(1:2:N) c1(1:2:N)];
0054 elseif (sym == 2)
0055   % symmetrically extend
0056   xe = symext(x, m0-1-k, k, 'e', 's');
0057   % filter
0058   c0 = conv2(xe, h0, 'valid');
0059   c1 = conv2(xe, h1, 'valid');
0060   % downsample
0061   w = [c0(1:2:N) c1(1:2:N)];
0062 elseif (sym == 3)
0063   % linear filtering
0064   c0 = conv(x, h0);
0065   c1 = conv(x, h1);
0066   % downsample
0067   w = [c0(1:2:end); c1(1:2:end)];
0068 end
0069

Generated on Mon 10-Jun-2013 23:03:23 by m2html © 2005