Calculates the gray-level co-occurrence matrix P of a gray-level image im.
P is a 4-dimensional matrix (histogram). The value P(i,j,d,theta) is the number of times that gray-level j occurs at a distance d and at an angle theta from gray-level i.
im is the input image which should contain integers in [0, levels-1], where levels indicate the number of gray-levels counted (typically 256 for an 8-bit image). distances and angles are vectors of the different distances and angles to use.
The following code
# Pattern Recognition Engineering (Nadler & Smith) # Digital Image Processing (Gonzales & Woods), p. 668 a = [0 0 0 1 2; 1 1 0 1 1; 2 2 1 0 0; 1 1 0 2 0; 0 0 1 0 1]; graycomatrix(a, 3, 1, [0 1]*-pi/4)
Produces the following output
ans = ans(:,:,1,1) = 2 5 1 5 1 2 1 3 0 ans(:,:,1,2) = 4 2 0 2 3 2 1 2 0
Package: image