Home > phiwave > uvi_wave > wt_dims.m

wt_dims

PURPOSE ^

returns output size and sizes of scales for matrix to be wt'ed

SYNOPSIS ^

function [wt_sz, sc_in_sz, sc_out_sz, scales] = wt_dims(sz, scales, p_dims)

DESCRIPTION ^

 returns output size and sizes of scales for matrix to be wt'ed 
 FORMAT [wt_sz, sc_in_sz, sc_out_sz, scales] = wt_dims(dims, scales, p_dims)
 
 Inputs 
 sz                  - current matrix size (1 by ndims) (dimensions size 1 are
                       ignored) 
 scales              - number of scales for wt (defaults to max)
 p_dims              - optional flags specifying dimensions to transform
 
 Outputs 
 wt_sz               - expected size (1 by ndims) after wt 

 sc_in_sz        - size of each block of data (one pre scale) to be entered
                       into wt (scales by ndims)
 sc_out_sz       - size of each block (one per scale) as output from wt
                       (scales by ndims) 
 scales              - number of scales for wt (will have been calculated
                       if empty on input)

 The problem is that the wt fpr one scale and one dimension may generate a
 matrix that is larger by 1 in the transformed dimension, because the wt
 will generate a padding 0 at the end before doing the wt, so that the
 ouputs can be decimated.  So we need to be able to predict the various
 sizes as we go through the wt, in order to get and set the data to/from
 the pre-wt and post-wt matrices.
 
 $Id: wt_dims.m,v 1.1 2004/09/26 04:00:24 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [wt_sz, sc_in_sz, sc_out_sz, scales] = wt_dims(sz, scales, p_dims) 
0002 % returns output size and sizes of scales for matrix to be wt'ed
0003 % FORMAT [wt_sz, sc_in_sz, sc_out_sz, scales] = wt_dims(dims, scales, p_dims)
0004 %
0005 % Inputs
0006 % sz                  - current matrix size (1 by ndims) (dimensions size 1 are
0007 %                       ignored)
0008 % scales              - number of scales for wt (defaults to max)
0009 % p_dims              - optional flags specifying dimensions to transform
0010 %
0011 % Outputs
0012 % wt_sz               - expected size (1 by ndims) after wt
0013 %
0014 % sc_in_sz        - size of each block of data (one pre scale) to be entered
0015 %                       into wt (scales by ndims)
0016 % sc_out_sz       - size of each block (one per scale) as output from wt
0017 %                       (scales by ndims)
0018 % scales              - number of scales for wt (will have been calculated
0019 %                       if empty on input)
0020 %
0021 % The problem is that the wt fpr one scale and one dimension may generate a
0022 % matrix that is larger by 1 in the transformed dimension, because the wt
0023 % will generate a padding 0 at the end before doing the wt, so that the
0024 % ouputs can be decimated.  So we need to be able to predict the various
0025 % sizes as we go through the wt, in order to get and set the data to/from
0026 % the pre-wt and post-wt matrices.
0027 %
0028 % $Id: wt_dims.m,v 1.1 2004/09/26 04:00:24 matthewbrett Exp $
0029 
0030 if nargin < 1
0031   error('Need input size(s)');
0032 end
0033 in_dims = find(sz > 1);
0034 max_scale = min(ceil(log2(sz(in_dims))));
0035 if nargin < 2
0036   scales = [];
0037 end
0038 if isempty(scales), scales = max_scale; end
0039 if scales > max_scale
0040   error(sprintf(['Scale %d too high. Maximum scale ' ...
0041          'for these dimensions is %d'], scales, max_scale));
0042 end
0043 n_dims = length(sz);
0044 if nargin < 3
0045   p_dims = ones(1, n_dims);
0046 end
0047          
0048 % default outputs
0049 sz = sz(:)';
0050 wt_sz = sz;
0051 sc_in_sz = ones(scales, 1) * sz;
0052 sc_out_sz = sc_in_sz;
0053 
0054 % avoid dimensions size 1
0055 in_dims = find(sz > 1 & p_dims);
0056 if isempty(in_dims), return, end
0057 
0058 % find scale sizes
0059 next_sizes = sz(in_dims);
0060 for sc = 1:scales
0061   sc_in_sz(sc, in_dims) = next_sizes;
0062   next_sizes =  ceil(sc_in_sz(sc, in_dims) / 2);
0063   sc_out_sz(sc, in_dims) = next_sizes * 2;
0064 end
0065 
0066 % overall output size
0067 wt_sz(in_dims) = sc_out_sz(scales, in_dims) ...
0068     + sum(sc_out_sz(1:scales-1, in_dims)/2, 1);

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