cooccurrence matrix

Given a position operator P(i,j), let A be a nxn matrix whose element A[i][j] is the number of times that points with grey level (intensity) g[i] occur, in the position specified by P, relative to points with grey level g[j]. Let C be the nxn matrix that is produced by dividing A with the total number of point pairs that satisfy P. C[i][j] is a measure of the joint probability that a pair of points satisfying P will have values g[i], g[j]. C is called a cooccurrence matrix defined by P. Examples for the operator P are: "i above j", "i one position to the right and two below j", etc.