Home > NoiseTools > nt_video_sns.m

nt_video_sns

PURPOSE ^

y=nt_video_sns(x,nneighbors) - apply SNS locally

SYNOPSIS ^

function y=nt_video_sns(x,nneighbors)

DESCRIPTION ^

y=nt_video_sns(x,nneighbors) - apply SNS locally

  y: processed data

  x: data to process (time * nrows * ncols)
  nneighbors: number of neighbors to incluce for each pixel

 Each channel is projected on its nneighbors closest neighbors, 
 and the channel is replaced by its projection.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y=nt_video_sns(x,nneighbors)
0002 %y=nt_video_sns(x,nneighbors) - apply SNS locally
0003 %
0004 %  y: processed data
0005 %
0006 %  x: data to process (time * nrows * ncols)
0007 %  nneighbors: number of neighbors to incluce for each pixel
0008 %
0009 % Each channel is projected on its nneighbors closest neighbors,
0010 % and the channel is replaced by its projection.
0011 
0012 if nargin<1; error('!'); end
0013 
0014 if nargin<2||isempty(nneighbors);
0015     disp('default nneighbors = 10');
0016     nneighbors=10;
0017 end
0018 
0019 [nframes,nrows,ncols]=size(x);
0020 x=x(:,:); 
0021 y=nan(size(x));
0022 
0023 closest=nt_proximity([nrows,ncols],nneighbors);
0024 for iPixel=1:size(closest,1)
0025     %disp(iPixel)
0026     xx=x(:,closest(iPixel,:));
0027     %[~,a]=nt_regw(x(:,iPixel),xx);
0028     %y(:,iPixel)=a;
0029     [V,D]=eig(xx'*xx); V=real(V); D=real(D);
0030     PCA_THRESH=10^-8;
0031     topcs=V(:,find(D/max(D) > PCA_THRESH)); % discard weak dims
0032     xxx=xx*topcs;
0033     b=( x(:,iPixel)'*xxx ) / (xxx'*xxx);    
0034     y(:,iPixel)=xxx*b';
0035 end
0036 y=reshape(y,[nframes,nrows,ncols]);
0037 
0038

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005