function N_features=cp_gabor2(x,FeatureFN,NonlinId,SmoothId,NormId,Structure,Decimation)
% CP_GABOR2  Comparative texture study: Gabor features, alternate decomp.
%	N_features=cp_gabor2(x,FeatureFN,NonlinId,SmoothId,NormId,...
%	  Structure,Decimation)

N_features=0;
[M_x,N_x]=size(x);

if     Structure== 7
  error('Structure 7 not yet implemented');
elseif Structure==14
  FreqLimits=[
    00/16+i*00/16 01/16+i*01/16
    00/16+i*01/16 01/16+i*02/16
    01/16+i*00/16 02/16+i*01/16
    01/16+i*01/16 02/16+i*02/16 
    00/08+i*01/08 01/08+i*02/08
    01/08+i*00/08 02/08+i*01/08
    01/08+i*01/08 02/08+i*02/08
    00/04+i*01/04 01/04+i*02/04
    01/04+i*00/04 02/04+i*01/04
    01/04+i*01/04 02/04+i*02/04 ];
elseif Structure== 6
  FreqLimits=[
    00/32+i*00/32 01/32+i*01/32
    00/32+i*01/32 01/32+i*02/32
    01/32+i*00/32 02/32+i*01/32
    01/32+i*01/32 02/32+i*02/32 
    00/16+i*01/16 01/16+i*02/16
    01/16+i*00/16 02/16+i*01/16
    01/16+i*01/16 02/16+i*02/16 
    00/08+i*01/08 01/08+i*02/08
    01/08+i*00/08 02/08+i*01/08
    01/08+i*01/08 02/08+i*02/08
    00/04+i*01/04 01/04+i*02/04
    01/04+i*00/04 02/04+i*01/04
    01/04+i*01/04 02/04+i*02/04 ];
elseif Structure==15
  FreqLimits=[
    00/64+i*00/64 01/64+i*01/64
    00/64+i*01/64 01/64+i*02/64
    01/64+i*00/64 02/64+i*01/64
    01/64+i*01/64 02/64+i*02/64 
    00/32+i*01/32 01/32+i*02/32
    01/32+i*00/32 02/32+i*01/32
    01/32+i*01/32 02/32+i*02/32 
    00/16+i*01/16 01/16+i*02/16
    01/16+i*00/16 02/16+i*01/16
    01/16+i*01/16 02/16+i*02/16 
    00/08+i*01/08 01/08+i*02/08
    01/08+i*00/08 02/08+i*01/08
    01/08+i*01/08 02/08+i*02/08
    00/04+i*01/04 01/04+i*02/04
    01/04+i*00/04 02/04+i*01/04
    01/04+i*01/04 02/04+i*02/04 ];
elseif Structure== 8
  FreqLimits=[];
  for k=0:3, for l=0:3, 
      FreqLimits=[FreqLimits;k/32+i*l/32 (k+1)/32+i*(l+1)/32]; 
  end, end
  for k=0:3, for l=0:3, 
      if (k>1) | (l>1), 
	FreqLimits=[FreqLimits;k/16+i*l/16 (k+1)/16+i*(l+1)/16]; 
      end
  end, end
  for k=0:3, for l=0:3, 
      if (k>1) | (l>1), 
	FreqLimits=[FreqLimits;k/08+i*l/08 (k+1)/08+i*(l+1)/08]; 
      end
  end, end
else
end

for FeatNum=1:size(FreqLimits,1)
  N_features=N_features+1;
  fprintf(1,'.');
  CtrFreq=abs(sum(FreqLimits(FeatNum,:))/2);
  CtrFreqSmth=abs((2*FreqLimits(FeatNum,1)+FreqLimits(FeatNum,2))/3);
  Angle=angle(sum(FreqLimits(FeatNum,:))/2);
  y=sepgabor(x,CtrFreq,Angle);
  v=cp_energy(y,NonlinId,SmoothId,NormId,CtrFreqSmth); % Local energy func.
  catframe(v,FeatureFN,[],'Interm',Decimation); % Write feature file
end

