scikit image - How do I mention the direction of neighbours to calculate the glcm in skimage/Python? -
i'd trouble understanding angle
parameter of greycomatrix
in skimage. in example mentioned in documentation compute glcm's pixel right , up, mention 4 angles. , 4 glcm's.
>>> image = np.array([[0, 0, 1, 1], ... [0, 0, 1, 1], ... [0, 2, 2, 2], ... [2, 2, 3, 3]], dtype=np.uint8) >>> result = greycomatrix(image, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4], levels=4)
what should parameters pixel right , down?
there's typo in example included in documentation of greycomatrix
(emphasis mine):
examples
compute 2 glcms: 1 1-pixel offset right, , 1 1-pixel offset upwards.
>>> image = np.array([[0, 0, 1, 1], ... [0, 0, 1, 1], ... [0, 2, 2, 2], ... [2, 2, 3, 3]], dtype=np.uint8) >>> result = greycomatrix(image, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4], ... levels=4)
indeed, result
contains four different glcm's rather two. these 4 matrices correspond possible combinations of 1 distance , 4 angles. calculate glcm corresponding "1-pixel offset right" distance , angle values should 1
, 0
, respectively:
result = greycomatrix(image, distances=[1], angles=[0], levels=4)
whereas calculate glcm corresponding "1-pixel offset upwards" parameters should 1
, np.pi/2
:
result = greycomatrix(image, distances=[1], angles=[np.pi/2], levels=4)
in example, distances=[1]
, angles=[0, np.pi/4, np.pi/2, 3*np.pi/4]
. select particular glcm 1 has specify appropriate indices angles
, distances
. thus, 1-pixel right glcm result[:, :, 0, 0]
, 1-pixel upwards glcm result[:, :, 0, 2]
.
finally, if wish calculate "1-pixel offset downwards" glcm (↓) have transpose "1-pixel offset upwards" glcm (↑). important note in cases both glcm's similar. in fact, can ignore order of co-occurring intensities setting parameter symmetric
true
in call greycomatrix
. doing so, al glcm's returned greycomatrix
symmetric.
Comments
Post a Comment