Home > NoiseTools > nt_multiscale.m

# nt_multiscale

## PURPOSE

z=nt_multiscale(x,depth) - apply smoothing at multiple scales

## SYNOPSIS

function z=nt_multiscale(x,depth,p)

## DESCRIPTION

    z=nt_multiscale(x,depth) - apply smoothing at multiple scales

       y: result

       x: data
       depth: depth of scales to investigate
       p: exponent to apply to smoothing window size (e.g. 1/2 --> half octave)

     NoiseTools

## CROSS-REFERENCE INFORMATION

This function calls:

- nt_multiscale z=nt_multiscale(x,depth) - apply smoothing at multiple scales

This function is called by:

- nt_multiscale z=nt_multiscale(x,depth) - apply smoothing at multiple scales

## SOURCE CODE

    0001 function z=nt_multiscale(x,depth,p)
    0002 %z=nt_multiscale(x,depth) - apply smoothing at multiple scales
    0003 %
    0004 %   y: result
    0005 %
    0006 %   x: data
    0007 %   depth: depth of scales to investigate
    0008 %   p: exponent to apply to smoothing window size (e.g. 1/2 --> half octave)
    0009 %
    0010 % NoiseTools
    0011
    0012 if nargin<3||isempty(p); p=1; end
    0013 if nargin<2; error('!'); end
    0014
    0015 if ndims(x)==3;
    0016     [m,n,o]=size(x);
    0017     z=zeros(m-2^depth-1,n*depth,o);
    0018     for k=1:o
    0019         z(:,:,k)=nt_multiscale(x(:,:,k),depth);
    0020     end
    0021     return
    0022 end
    0023
    0024 [m,n]=size(x);
    0025 z=zeros(m,n,depth);
    0026
    0027 z(:,:,1)=x(1:size(z,1),:);
    0028 for k=1:depth-1
    0029     step=2^k-1;
    0030     step=floor(step.^p);
    0031     idx=1:(m-step);
    0032     z(idx,:,k+1) = (...
    0033         z(idx,:,k) + ...
    0034         z(idx+step,:,k) )/2; % next column is mean of previous with time-shifted previous
    0035 end
    0036 z=z(1:end-step,:,:);
    0037 %z=reshape(z,[size(z,1),n*depth]);
    0038