function N_features=cp_cooc(x,FeatureFN,N_block,N_gray,Decimation)
% CP_COOC  Comparative texture measure study: Co-occurrence
%	N_features=cp_cooc(x,FeatureVarNo,[N_1 N_2],N_G,Decimation)
%	N_1 and N_2 defines the block size, N_G the number of gray levels to
%	use 

% Preprocessing/checking
m=[min(x(:)) max(x(:))];
if (m(2)-m(1)<170) | (m(2)-m(1)>290)
  fprintf(2,'\07');
  fprintf(2,'WARNING cp_cooc assumes integer input images with ~256 gray\n');
  fprintf(2,'        levels. This image has %d gray levels\n',m(2)-m(1));
end
x=floor(N_gray*x/256);

% Feature extraction
d=[0 1;1 1;1 0;1 -1];
% d=[1 -1]; % DEBUGGING
for d_idx=1:size(d,1)
  [asm,con,cor,ent]=cooc(x,d(d_idx,:),N_block);
  catframe(asm,FeatureFN,[],'Interm',Decimation);
  catframe(con,FeatureFN,[],'Interm',Decimation);
  catframe(cor,FeatureFN,[],'Interm',Decimation);
  catframe(ent,FeatureFN,[],'Interm',Decimation);
end
fprintf(1,'\n');

N_features=4*size(d,1);

