%  texture cooccurence based stat
clear 
x2=[52    71    72    74    64    55    43    74;
   105    56    75    77    64    60    53    78;
   168    68    69    76    69    62    58    71;
   162   142    56    75    73    64    60    53;
   162   180    89    67    79    68    63    30;
   186   175   156    61    78    72    63    53;
   210   171   192    87    67    77    67    59;
   250   158   188   140    59    77    69    61] % input
x2=fix(x2/32) % intensity quantized image 
x2=mat2gray(x2);
offsets=[0 1] % cooccurence defined 
[gs]=graycomatrix(x2,'NumLevels',8,'Offset',offsets,'Graylimits',[])
sum(gs(:))
offsets=[1 1] % cooccurence defined 
[gs]=graycomatrix(x2,'NumLevels',8,'Offset',offsets,'Graylimits',[])
sum(gs(:))
p=gs/sum(gs(:))
E=0;
for m=1:8
    for n=1:8
        if (p(m,n)>eps)
            E=E+p(m,n) * log2(p(m,n));
        end
    end
end
E=-E % entropy
%
C=0;
for m=0:7
    for n=0:7
      C=C+(m-n)^2 * p(m+1,n+1);
    end
end
C
%
U=0;
for m=0:7
    for n=0:7
      U=U+ p(m+1,n+1) * p(m+1,n+1);
    end
end
U
%
C=0;
for m=0:7
    for n=0:7
      C=C+(m-n)^2 * p(m+1,n+1);
    end
end
C
%%
H=0;
for m=0:7
    for n=0:7
      H=H+  (p(m+1,n+1))/(1+abs((m-n)));
    end
end
H
%
mbar=0;
for m=0:7
    for n=0:7
      mbar=mbar+(m) * p(m+1,n+1);
    end
end
mbar;
nbar=0;
for m=0:7
    for n=0:7
      nbar=nbar+(n) * p(m+1,n+1);
    end
end
nbar;
sigm=0;
for m=0:7
    for n=0:7
      sigm=sigm+(m-mbar)^2 * p(m+1,n+1);
    end
end
sigm;
sign=0;
for m=0:7
    for n=0:7
      sign=sign+(n-nbar)^2 * p(m+1,n+1);
    end
end
sign;
R=0;
for m=0:7
    for n=0:7
      R=R+(m-mbar) *(n-nbar)  * p(m+1,n+1);
    end
end
R/(sqrt(sigm)*sqrt(sign))
stats=graycoprops(gs,'all')