Skip to content

Preserve pixel shape for single-band NDVI selections - #187

Open
antonsoo wants to merge 3 commits into
spectralpython:developfrom
antonsoo:fix/ndvi-single-band-selectors
Open

antonsoo wants to merge 3 commits into
spectralpython:developfrom
antonsoo:fix/ndvi-single-band-selectors

Conversation

@antonsoo

Copy link
Copy Markdown

Reduce the selected-band axis whenever it is present, including when it contains one band. For example, ndvi(data, [red], nir) currently raises on a rectangular image or broadcasts into an extra dimension on a square image. Loaded ImageArray inputs also retain the band axis with scalar selectors, so even ndvi(image.load(), red, nir) returns an extra dimension.

Both cases now return one NDVI value per pixel, consistent with scalar selection on an ordinary array and the existing multiband averaging behavior.

Add regression coverage for singleton lists, tuples, arrays and slices, mixed singleton/multiband selections, and a loaded AVIRIS image. All 13 NDVI tests pass on Python 3.8/NumPy 1.24 and Python 3.12/NumPy 2.5. The five numerical test files pass 162 tests, and the required Flake8 check passes.

A separate audit of the official AVIRIS sample checks 60 region/container/band-selection configurations against per-pixel band means. All 60 now have the expected shape and values; the 12 previously working configurations remain byte-for-byte identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant