Skip to content

Highly efficient GLCM/X-GLCM feature extractor for python.

Notifications You must be signed in to change notification settings

lmoesch/py-glcm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Installation

python setup.py install

Usage

  • [Grey Level Co-occurance Matrix](# Grey Level Co-occurance Matrix)
  • [glcm](# glcm.glcm)
  • xglcm
  • GLCM Features

Grey Level Co-occurance Matrix

glcm.glcm

glcm.glcm(array, dists, dirs, mode, symmetric=True, bins=256, normalized=True, check=True)

Generates a GLCM.

Parameters:
array : array_like

  Input image, either 2D or 3D.

dists : array_like

  Array of desired integer distances [d1, d2, ..., dn].

dirs : array_like

  Array of desired integer directions [d1, d2, ..., dn]. 1 Corresponds to N, 2 to NE, 3 to E, ... and 8 to NW.

Caution! Directions will be reordered ascendingly. To avoid confused outputs, please make sure to provide an ordered array.
mode : string

Operation mode of the glcm. Features "sum" and "raw".

In raw-mode a glcm is generated for every combination of distances and directions.

In sum-mode all desired directions are added together so only one glcm per distance is generated. This is far more efficient than summing up afterwards.

symmetric : boolean, optional
Caution! Running in symmetric mode will remove opposing directions and will replace directions 5 to 8 with their corresponding counterparts! To avoid confusing outputs please make sure only to use directions 1 to 4 in symmetric mode!
bins : int, optional

Number of bins. When input checking is enabled, the input image is binned to this number if the maximum image value exceeds the number of bins. This happens aswell if the input image is not of integer type.

normalized : boolean, optional
Determines if the output shall be normalized or not.
Caution! The normalization will fail if the input image has more than 10^15 pixels.
check : boolean, optional
Determines if the input should be checked for correctness.
Returns: glcm : ndarray

Array of glcm(s) with the following shape:

[distances][directions][channels][bins][bins]

glcm.xglcm

glcm.xglcm(array, dists, dirs, mode, symmetric=True, bins=256, normalized=True, check=True)

Generates a GLCM for every channel combination.

**Parameters:** **array** : _array_like_

Input image with three dimensions with shape [dimx, dimy, channels]

**dists** : _array_like_

Array of desired integer distances [d1, d2, ..., dn].

**dirs** : _array_like_

Array of desired integer directions [d1, d2, ..., dn]. 1 Corresponds to N, 2 to NE, 3 to E, ... and 8 to NW.

Caution! Directions will be reordered ascendingly. To avoid confused outputs, please make sure to provide an ordered array.

**mode** : _string_

Operation mode of the glcm. Features "sum" and "raw".

In raw-mode a glcm is generated for every combination of distances and directions.

In sum-mode all desired directions are added together so only one glcm per distance is generated. This is far more efficient than summing up afterwards.

**symmetric** : _boolean, optional_

Caution! Running in symmetric mode will remove opposing directions and will replace directions 5 to 8 with their corresponding counterparts! To avoid confusing outputs please make sure only to use directions 1 to 4 in symmetric mode!

**bins** : _int, optional_

Number of bins. When input checking is enabled, the input image is binned to this number if the maximum image value exceeds the number of bins. This happens aswell if the input image is not of integer type.

**normalized** : _boolean, optional_ Determines if the output shall be normalized or not.

Caution! The normalization will fail if the input image has more than 10^15 pixels.

**check** : _boolean, optional_ Determines if the input should be checked for correctness.
**Returns:** **glcm** : _ndarray_

Array of glcm(s) with the following shape:

[distances][directions][source channels][target channels][bins][bins]

GLCM Features

glcm.glcm_features

glcm.glcm_features(array, features, symmetric=True, normalized=True)

Calculates features from a given set of GLCMs

**Parameters:** **array** : _array_like_

Array of glcms with shape where the last two axes covering the glcm entries.

**features** : _int_

Binary input that determines the desired features. See below.

**symmetric** : _boolean, optional_

Indicates if the input GLCM(s) are symmetric or not.

**normalized** : _boolean, optional_ Determines if the input is normalized.
**Returns:** **glcm** : _dict_

Dictionary of features.

Supported Features

Angular Second Moment

glcm.asm, dictionary: "ASM"

Measurement of homogeneous patterns in the image.

Contrast

glcm.contrast, dictionary: "Contrast"

Correlation

glcm.correl, dictionary: "Correlation"

Not implemented yet

Autocorrelation

glcm.autocorrel, dictionary: "Auto Correlation"

Sum of Squares

glcm.ssq, dictionary: "SSQ"

Not implemented yet

Inverse Difference Moment

glcm.idm, dictionary: "IDM"

Inverse Difference

glcm.idf, dictionary: "IDF"

Sum Average

glcm.sumavg, dictionary: "Sum Average"

Sum Variance

glcm.sumvar, dictionary: "Sum Variance"

Sum Entropy

glcm.sumentrp, dictionary: "Sum Entropy"

Difference Average

glcm.diffavg, dictionary: "Diff Average"

Difference Variance

glcm.diffvar, dictionary: "Diff Variance"

Not implemented yet

Difference Entropy

glcm.diffentrp, dictionary: "Diff Entropy"

Cluster Prominence

glcm.clusterprom, dictionary: "Cluster Prominence"

Cluster Shade

glcm.clustershade, dictionary: "Cluster Shade"

Cluster Tendency

glcm.clustertend, dictionary: "Cluster Tendency"

Dissimilarity

glcm.Dissim, dictionary: "Dissimilarity"

About

Highly efficient GLCM/X-GLCM feature extractor for python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published