Home > NoiseTools > nt_multismooth_old.m

# nt_multismooth_old

## PURPOSE

z=nt_multismooth(x,smooth,alignment,diff_flag) - apply multiple smoothing kernels

## SYNOPSIS

function z=nt_multismooth(x,smooth,alignment,diff_flag)

## DESCRIPTION

    z=nt_multismooth(x,smooth,alignment,diff_flag) - apply multiple smoothing kernels

       y: result

       x: matrix to smooth
       smooth: vector of smoothing kernel sizes
       alignment: -1: left [default], 0: center
       diff_flag: if true, return 1sr colum & between-column differences

     X is smoothed column by column (all smoothed versions of 1st column, then all
     of second column, etc).

     X may be 1D, 2D or 3D. See also nt_multishift.

     NoiseTools

## CROSS-REFERENCE INFORMATION

This function calls:

- nt_greetings nt_greetings - display message the first time the toolbox is used
- nt_multismooth z=nt_multismooth(x,smooth,alignment,diff_flag) - apply multiple smoothing kernels
- nt_smooth y=nt_smooth(x,T,nIterations,nodelayflag) - smooth by convolution with square window

This function is called by:

## SOURCE CODE

    0001 function z=nt_multismooth(x,smooth,alignment,diff_flag)
    0002 %z=nt_multismooth(x,smooth,alignment,diff_flag) - apply multiple smoothing kernels
    0003 %
    0004 %   y: result
    0005 %
    0006 %   x: matrix to smooth
    0007 %   smooth: vector of smoothing kernel sizes
    0008 %   alignment: -1: left [default], 0: center
    0009 %   diff_flag: if true, return 1sr colum & between-column differences
    0010 %
    0011 % X is smoothed column by column (all smoothed versions of 1st column, then all
    0012 % of second column, etc).
    0013 %
    0014 % X may be 1D, 2D or 3D. See also nt_multishift.
    0015 %
    0016 % NoiseTools
    0017 nt_greetings;
    0018
    0019 if nargin<4 || isempty(diff_flag); diff_flag=0; end
    0020 if nargin<3 || isempty(alignment); alignment=-1; end
    0021 if nargin<2; error('!'); end
    0022 if min(smooth)<1; error('smooth must be positive'); end
    0023
    0024 if iscell(x)
    0025     for iCell=1:length(x);
    0026         z{iCell}=nt_multismooth(x{iCell},smooth,alignment);
    0027     end
    0028     return
    0029 end
    0030
    0031 if size(x,1)<max(smooth); error('smoothing kernel size should be no larger than nrows'); end
    0032 if min(smooth)<0; error('smoothing kernel size should be nonnegative'); end
    0033 smooth=smooth(:)';
    0034 nsmooth=numel(smooth);
    0035
    0036 % array of shift indices
    0037 [m,n,o]=size(x);
    0038 z=zeros(m,n*nsmooth,o);
    0039
    0040 for iPage=1:o
    0041     zz=zeros(m,n,nsmooth);
    0042     for iSmooth=1:nsmooth
    0043         if alignment==-1; nodelayflag=0; elseif alignment==0; nodelayflag=1; else; error('!!'); end
    0044         zz(:,:,iSmooth)=nt_smooth(x(:,:,iPage),smooth(iSmooth),[],nodelayflag);
    0045     end
    0046     if diff_flag
    0047         zz=cat(3,zz(:,:,1),diff(zz,[],3));
    0048     end
    0049     zz=permute(zz,[1,3,2]);
    0050     zz=reshape(zz,m,n*nsmooth);
    0051     z(:,:,iPage)=zz;
    0052 end
    0053
    0054