function N_features=cp_nnfilt(x,FeatureFN,ImageId,NonlinId,SmoothId,NormId,FeatDec,N_tex,MaskSize,Nodes)
% 					CP_NNFILT  Comparative texture measure study: Jain/Karus method

% fprintf(1,'DEBUG edition of NNFilt\n');

N_features=1;
TrainImgList='';

ParamFN=tempnam;

% Design
for TexNo=1:N_tex
  % Filter design
  eval(sprintf('x_%d=cp_image(ImageId,TexNo);',TexNo));
  if N_tex>10
    eval(sprintf('x_%d=x_%d(1:128,1:128);',TexNo,TexNo));
  end
  TrainImgList=sprintf('%s,x_%d',TrainImgList,TexNo);
end
eval(sprintf(...
  'y=nnfilt(x,''%s'',''Nodes'',Nodes,''MaskSize'',MaskSize%s);',...
  ParamFN,TrainImgList));

z=cp_energy(y,NonlinId,SmoothId,NormId,[5 5]);  % Local energy function

catframe(z,FeatureFN,[],'Interm',FeatDec);  % Write feature file
% DEBUG
!ll /tmp/.tmp.*

eval(sprintf('!rm -f %s',ParamFN));


