function [m1,m2,m3,m4,m5,m6,m7,m8] = tm1(a,w,k,l,dr,dc)
%
%
% On input:
%     a: gray level image
%     w: window size (odd number)
%     k: power of gray level difference
%     l: power of probablility
%    dr: row offset
%    dc: column offset
% On output:
%    m1,m2,...,m8 - Image defining function
% Call:
%    [m1,m2,m3,m4,m5,m6,m7,m8] = tm1(a,w,k,l,dr,dc)
%


[am,an] = size(a);


m1 = zeros(am,an); m2 = zeros(am,an); m3 = zeros(am,an); m4 = zeros(am,an);
m5 = zeros(am,an); m6 = zeros(am,an); m7 = zeros(am,an); m8 = zeros(am,an);

halfwin = (w-1)/2; 
cmin = 1+halfwin; rmin = 1+halfwin; rmax = am-halfwin; cmax = an-halfwin;

for c = cmin:cmax
  for r = rmin:rmax
      win = a(r-halfwin:r+halfwin,c-halfwin:c+halfwin);
      p = cooccur(win,dc,dr);
      m1(r,c) = coocm1(p); m2(r,c) = coocm2(p); m3(r,c) = coocm3(p); 
      m4(r,c) = coocm4(p,k,l); m5(r,c) = coocm5(p,k,l); m6(r,c) = toocm6(a,p);
      m7(r,c) = coocm7(p,k); m8(r,c) = toocm8(p,l);
  end
end


