function h = tmhomogen(P)
%
% tmhomogen - Compute homogeneity of cooccurrence matrix
% On input:
%     P: 2D cooccurrence matrix
% On output:
%     h: homogeneity
% Call:
%     h = tmhomogen(P);
%

[m,n] = size(P);
sum = 0;
for r = 1:m
  for c = 1:n
    denom = 1 + abs((r-1)-(c-1));
    sum = sum + P(r,c)/denom;
  end
end
h = sum;
