0001 function z=nt_multiscale(x,depth)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if nargin<2; error('!'); end
0012
0013 if ndims(x)==3;
0014 [m,n,o]=size(x);
0015 z=zeros(m-2^depth-1,n*depth,o);
0016 for k=1:o
0017 z(:,:,k)=nt_multiscale(x(:,:,k),depth);
0018 end
0019 return
0020 end
0021
0022 [m,n]=size(x);
0023 z=zeros(m,n,depth);
0024
0025 z(:,:,1)=x(1:size(z,1),:);
0026 for k=1:depth-1
0027 step=2^k-1;
0028 idx=1:(m-step);
0029 z(idx,:,k+1) = (...
0030 z(idx,:,k) + ...
0031 z(idx+step,:,k) )/2;
0032 end
0033
0034 z=reshape(z,[m,n*depth]);
0035 z=z(1:end-2^depth-1,:);