Merged
Conversation
New xrspatial.glcm module with glcm_texture() for computing Haralick texture features (contrast, dissimilarity, homogeneity, energy, correlation, entropy) over a sliding window. Supports numpy, dask+numpy, cupy, and dask+cupy backends. Dask path pre-quantizes globally for consistent gray-level mapping across chunks.
29 tests covering validation, quantization, known-value checks, NaN handling, edge cases, all six metrics, angle averaging, and cross-backend consistency (numpy vs dask, cupy, dask+cupy).
Add glcm_texture to the focal reference docs and to the README feature matrix. CuPy/Dask+CuPy marked as CPU-fallback.
Demonstrates single/multi metric usage, angle effects, Dask support, and parameter reference on a synthetic four-texture raster.
Standalone script with a six-zone synthetic raster. Keyboard controls cycle through metrics, window sizes, gray levels, and angles. Clicking a pixel shows its local GLCM matrix and a bar chart of all six Haralick feature values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
glcm_texture()function inxrspatial/glcm.py, per #963.Computes six Haralick GLCM metrics (contrast, dissimilarity, homogeneity, energy, correlation, entropy) over a sliding window. Pass a single metric name for a 2-D result, or a list for a 3-D result with a leading
metricdimension.Backends:
map_overlapcupy.asnumpyParameters:
window_size(odd, >= 3),levels(2-256),distance(pixel pair spacing),angle(0/45/90/135 or None to average all four).Other changes:
docs/source/reference/focal.rstexamples/user_guide/22_GLCM_Texture.ipynb)__init__.pyand.xrsaccessorCloses #963
Test plan
pytest xrspatial/tests/test_glcm.py-- 29 tests pass