Usage (GLCM Cross)

Given that ar is an np.ndarray.

OOP GLCM Cross Transform

>>> from glcm_cupy import GLCMCross
>>> g = GLCMCross(...).run(ar)

Functional GLCM Cross Transform

>>> from glcm_cupy import glcm_cross
>>> g = glcm_cross(ar, ...)

I/O

For a np.ndarray or cp.ndarray input, the algorithm will output a np.ndarray or cp.ndarray respectively.

Input Array Requirements

  • Shape: \(B\times H\times W\times C\) or \(H\times W\times C\)

  • Non-negative, integer array

  • Must be large enough for radius

  • Must have at least 2 channels to cross

\[\begin{split}B: \text{Batches}\\ H: \text{Height}\\ W: \text{Width}\\ C: \text{Channel}\end{split}\]

Output Array

  • Shape: \(B\times H^*\times W^*\times C_{combo}\times F\) or \(H\times W\times C_{combo}\times F\)

  • 0 to 1 if normalize_features, else it depends on feature.

\[\begin{split}H^*: H - \text{Radius} \times 2\\ W^*: W - \text{Radius} \times 2\\ C_{combo}: {C \choose 2} = \text{Number of Pair Combinations}\\ F: \text{Features}\end{split}\]

Combinations

The pair combination order is dependent on itertools.combinations.

For example, for an image with 4 channels:

>>> from itertools import combinations
>>> n_channels = 4
>>> pair_combinations = combinations(range(n_channels), 2)
>>> print(pair_combinations)
[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]

We see that the 1st channel crosses Channel 0 and Channel 1.

Arguments

Argument

Description

Default

features

List of GLCM.Features for GLCM to use

(Features.HOMOGENEITY, Features....)

ix_combos

List of pair combinations to use

None (All combinations)

radius

Radius of GLCM Windows

2

bin_from

Maximum Value + 1 of the array.

256

bin_to

Maximum Value + 1 of the array

256

normalized_features

Whether to scale features to [0, 1]

True

verbose

Whether tqdm outputs progress

True

max_partition_size1

No. of windows parsed per GLCM Matrix

10000

max_threads1

No. of threads per CUDA block

512

See also

Learn how to use glcm-cupy from the examples in the sidebar on the left!


1(1,2)

Recommend to not change.