Repository navigation
fix(glcm): refuse a ROI whose 2D co-occurrence matrix cannot be held on its own - #544
Merged
Merged
Conversation
vjaganat90
approved these changes
Nov 12, 2026
vjaganat90
left a comment
Member
There was a problem hiding this comment.
LGTM.
I measured it against its base 697eaeb.
- Isolation. Two 4 × 4 ROIs in IBSI mode: one with a maximum of 46341 or 65535, the other with levels up to 200. I ran both orders, in memory and out of core. In all eight runs the small ROI's 149
GLCM_*columns equal its run alone, the refused ROI reads 0 in every column, and stderr names it. - The base. On the base the out-of-core run raises
RuntimeErrorand peaks at 4.9 GB; the head peaks at 120 MB. - Unchanged values. 6705 GLCM values on three random images, in IBSI and default mode, match the base exactly.
Nit
- not_covered.md:20: the heading should say 117, not 111, since that is what section A's tables sum to at this head.
main's tables already summed to 111 before this PR, and it adds 6 (3 intest_2d_glcm_mechanics.h, 3 in the new.py). #535 rewrites the same line to 113, so whichever merges second needs the sum taken again (119 with both).
added 2 commits
November 17, 2026 08:20
…on its own In IBSI mode the matrix has one row and column per grey level up to the ROI's maximum. Above 46340 levels the size check overflowed int and threw, and the reduce workers drop that exception, so the rest of the batch kept unset values and every GLCM column came out 0. A ROI above that limit, or whose matrix cannot be allocated, now gets the noval substitute for itself and a message naming it on stderr. The other ROIs are calculated as usual, in RAM and out of core. Refs PN-235
The mechanics header is a scanned source of the GLCM registry, so asserting on GLCM_ASM_AVE there counted as coverage the registry row does not list, and the registry check failed. The test now walks GLCMFeature::featureset and requires every value of every feature to differ from the substitute. Refs PN-235
darkclad
force-pushed
the
main-glcm-ibsi-alloc
branch
from
November 17, 2026 16:52
7c7eb56 to
d085aab
Compare
vjaganat90
approved these changes
Nov 18, 2026
vjaganat90
left a comment
Member
There was a problem hiding this comment.
LGTM. Against 7c7eb56 the rebase changes only tests/vetting/not_covered.md: section A's totals (34 files, 124 test functions; A.1 27 files) now sum from its tables, which settles my nit. main changed no GLCM source in between, so the measurements from my earlier review stand.
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
Fixes one ROI's GLCM allocation refusal in IBSI mode zeroing the GLCM values of other ROIs in the image (PN-235).
In IBSI mode the 2D co-occurrence matrix has one row and column per grey level up to the ROI's maximum. The size check multiplied width by height in
int, which overflows from 46341 levels, so it threw on every machine.runParalleldrops the futures of its workers, so the exception was lost and the rest of that worker's batch kept unset values. Which ROIs went to 0 depended on their order.Change
GLCMFeature::calculatehandles a ROI whose matrix cannot be held: every GLCM value of that ROI gets the--novalsubstitute (0 from Python) and a message on stderr names the ROI. Because this is incalculate, the in-RAM and out-of-core paths behave the same.SimpleMatrixcan index. This is the boundary at which the old check already fired, so no ROI that computed before is refused now.No formula changes. A ROI below the limit gets the same values as before.
Changed values
All 149 2D
GLCM_*columns (per-angle and_AVE), only for images with a ROI above 46340 levels in IBSI mode, or with--coarseGrayDepthabove 46340. Fixture: two 4x4 ROIs, one with maximum 65535, the other with levels up to 200, the refused ROI first.GLCM_ASM_0GLCM_*GLCM_*--novalsubstitute, ROI named on stderrTests
tests/python/test_2d_glcm_mechanics.py: isolation in both ROI orders at maxima 46341 and 65535, the same in RAM against out of core, and 8-bit ROIs not refused.tests/test_2d_glcm_mechanics.h: a custom noval reaches every feature value, and a small ROI is not refused.The new tests fail on the previous code.
Known limits
bad_allocbranch has no test, because forcing it would need an allocator seam.Related
PN-135 tracks the general
runParallelbehaviour. PN-260 tracks the sameintsize check in 3D GLCM and the IDM grey-level-difference overflow; this PR covers its 2D size-check part.