%  texture  histogram based stat
clear 
x2=[0   19   20   22;
   53    4   23   25;
  116   16   17   24;
  110   90    4   23] % input
%
N=size(x2);
his=zeros(1,256);
for k=1:N(1) % find histogram
  for m=1:N(1)
    his(x2(k,m)+1) = his(x2(k,m)+1) +1;
  end
end
p=his./numel(x2); % normaized histogram
L=length(p);
x2=double(x2);
%
xmean=mean(x2(:)) % mean
sum([0:255].*p) % mean
%%%% stat based on hist
x3mom=0;x2mom=0;
for m=0:255
  x3mom=x3mom+(m-xmean)^3 *p(m+1);
  x2mom=x2mom+(m-xmean)^2 *p(m+1);
end
ss=x3mom;
varn=x2mom/(255^2);
std=sqrt(x2mom)
sk=ss/(255^2)
smooth=1-(1/(1+varn))
%
xu=0;xe=0;
for m=0:255
  xu=xu+p(m+1) * p(m+1);
  if p(m+1) > eps
     xe=xe+(p(m+1) * log2(p(m+1)));
  end
end
xu % energy
xe=-xe % entropy
        
