Home > phiwave > @phiw_wavelet > levels.m

levels

PURPOSE ^

returns indices for levels, quadrants for data size odim

SYNOPSIS ^

function [inplevs, quads, nquads] = levels(w, odim, scales)

DESCRIPTION ^

 returns indices for levels, quadrants for data size odim
 FORMAT [inplevs, quads] = levels(w, odim, scales)
 
 Inputs
 w      - wavelet
 odim   - dimension of wavelet transformed data
 scales - number of scales used by wavelet transform
 
 Output
 inplevs - index limits for each scale, before xform, within the matrix size (odim)
 quads  - scales by quadrants cell matrix giving index limits for 
          quadrants (at each scale) from wt
 nquads - no of quadrants

 This template wavelet function assumes dyadic dimensions

 $Id: levels.m,v 1.3 2005/06/05 04:42:22 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [inplevs, quads, nquads] = levels(w, odim, scales)
0002 % returns indices for levels, quadrants for data size odim
0003 % FORMAT [inplevs, quads] = levels(w, odim, scales)
0004 %
0005 % Inputs
0006 % w      - wavelet
0007 % odim   - dimension of wavelet transformed data
0008 % scales - number of scales used by wavelet transform
0009 %
0010 % Output
0011 % inplevs - index limits for each scale, before xform, within the matrix size (odim)
0012 % quads  - scales by quadrants cell matrix giving index limits for
0013 %          quadrants (at each scale) from wt
0014 % nquads - no of quadrants
0015 %
0016 % This template wavelet function assumes dyadic dimensions
0017 %
0018 % $Id: levels.m,v 1.3 2005/06/05 04:42:22 matthewbrett Exp $
0019   
0020 if nargin < 3
0021   error('Need odim and scales to return level info');
0022 end
0023 
0024 % defining quadrants per level
0025 ndims = length(odim);
0026 nquads = 2^ndims;
0027 qs = 0:(nquads-1); 
0028 % flag to note that detail coefficients go to
0029 % right of data vector (as for UviWave)
0030 if w.detail_right, qs = fliplr(qs); end
0031 
0032 % get quadrants (including low) by analogy to ind2sub for
0033 % matrix of size ones(ones(1,ndims)*2)
0034 dsz = 2.^(0:ndims-1); % dimension sizes
0035 for dim = ndims:-1:1
0036   quad_add(:,dim) = floor(qs/dsz(dim))';
0037   qs = rem(qs,dsz(dim));
0038 end
0039 
0040 bdim = odim;
0041 stpos = ones(1,ndims);
0042 quads = cell(scales+1,1);
0043 inplevs = cell(scales+1,1);
0044 inplevs{1} = [ones(1, ndims);odim];
0045 for l=1:scales
0046   bdim = bdim / 2;
0047   tdim = [zeros(1,ndims);bdim-1];
0048   stadd = [1;1] * stpos;
0049   for q=1:nquads-1;
0050     qm{q} = stadd + tdim + [1;1]*((quad_add(q,:).*bdim));
0051   end
0052   quads{l} = qm;
0053   % move to next low origin
0054   stpos = stpos + (quad_add(nquads,:).*bdim);
0055   % and store in levels matrix
0056   inplevs{l+1} = [1;1] * stpos + tdim;
0057 end
0058 % lowest pass level
0059 quads{scales+1}(1) = inplevs(scales+1);

Generated on Wed 06-Jul-2005 18:07:21 by m2html © 2003