function con = tmcontrast(P,k,l)
%
% tmcontrast - Compute contrast on cooccurrence matrix
% On input:
%     P: 2D cooccurrence matrix
%     k: power of gray level difference
%     l: power of probability 
% On output:
%     con: contrast
% Call:
%     con = tmcontrast(P,k,l);
%

[m,n] = size(P);
sum = 0;
for r = 1:m
  for c = 1:n
      sum = sum + ((abs((r-1)-(c-1)))^k)*(P(r,c)^l);
  end
end
con = sum;
