Binning

To reduce the time taken for GLCM, we shrink GLCM size by limiting the maximum value of the input.

Note

E.g. an image of max value 255 requires \(256\times 256\) sized GLCM. Binning it to 15 will drastically reduce to \(16\times 16\).

The arguments used are bin_from=256 and bin_to=16.

>>> from glcm_cupy import GLCM
>>> import numpy as np
>>> from PIL import Image
>>> ar = np.asarray(Image.open("image.jpg"))
>>> g = GLCM(..., bin_from=256, bin_to=16).run(ar)

Warning

As we include 0, if an image’s max value is 255, use bin_from=256 .

Time Scale

The time complexity is \(O(n^2)\)

E.g. bin_to==a -> bin_to==a * 2, the time needed scales by 4

Recommendations

Try bin_to<=16 for testing purposes, then increase when ready to use higher bins.

>>> from glcm_cupy import GLCM, Direction
>>> g = GLCM(bin_from=256, bin_to=16)