From: Stig Geerts on
the Numlevels parameter is used to scale the image into (even?) bins.
So when you would calculate the graycomatrix of a vector goint from 0 to 255 and you set Numlevels to 8. You should get 32 , 1's,2's,...,8's.

B(1,:) = 0:31;
B(2,:) = 32:63;
B(3,:) = 64:95;
B(4,:) = 96:127;
B(5,:) = 128:159;
B(6,:) = 160:191;
B(7,:) = 192:223 ;
B(8,:) = 224:255;
[m,SI] = graycomatrix(B,'NumLevels',8,'GrayLimits',[0 255]);
for i = 1 : 8
numel(find(SI==i))
end

INSTEAD : matlab returns following bins (as can be seen in SI)
Graylevel values
Bin1 = 0-18;
Bin2 = 19-45;
....
While they should all be 32 in size.

WHY ARE THEY NOT EVENLY SCALED ???

Sincerely