Home > NoiseTools > nt_multismooth.m

nt_multismooth

PURPOSE ^

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

SYNOPSIS ^

function z=nt_multismooth(x,smooth,alignment)

DESCRIPTION ^

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

   y: result

   x: matrix to smooth
   smooth: vector of smoothing kernel sizes
   alignment: -1: left [default], 0: center, 1:right
 
 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: This function is called by:

SOURCE CODE ^

0001 function z=nt_multismooth(x,smooth,alignment)
0002 %z=nt_multismooth(x,smooth,alignment) - 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, 1:right
0009 %
0010 % X is smoothed column by column (all smoothed versions of 1st column, then all
0011 % of second column, etc).
0012 %
0013 % X may be 1D, 2D or 3D. See also nt_multishift.
0014 %
0015 % NoiseTools
0016 nt_greetings;
0017 
0018 if nargin<3 || isempty(alignment); alignment=-1; end
0019 if nargin<2; error('!'); end
0020 if min(smooth)<1; error('smooth must be positive'); end
0021 
0022 if iscell(x)
0023     for iCell=1:length(x);
0024         z{iCell}=nt_multismooth(x{iCell},smooth,alignment);
0025     end
0026     return
0027 end
0028 
0029 if size(x,1)<max(smooth); error('smoothing kernel size should be no larger than nrows'); end
0030 if min(smooth)<0; error('smoothing kernel size should be nonnegative'); end
0031 smooth=smooth(:)';
0032 nsmooth=numel(smooth);
0033 
0034 % array of shift indices
0035 [m,n,o]=size(x);
0036 z=zeros(m,n*nsmooth,o);
0037 
0038 for iPage=1:o
0039     zz=zeros(m,n,nsmooth);
0040     for iSmooth=1:nsmooth
0041         if alignment==-1; nodelayflag=0; elseif alignment==0; nodelayflag=1; else; error('not implemented'); end
0042         zz(:,:,iSmooth)=nt_smooth(x(:,:,iPage),smooth(iSmooth),[],nodelayflag);
0043     end
0044     zz=permute(zz,[1,3,2]); 
0045     zz=reshape(zz,m,n*nsmooth);
0046     z(:,:,iPage)=zz;
0047 end
0048 
0049

Generated on Tue 09-Oct-2018 10:58:04 by m2html © 2005