Fix/degenerate object shapes - #35
Merged
Merged
Conversation
…verage
A single isolated foreground pixel (a perfectly valid object, e.g. from a
noisy segmentation) crashed the whole pipeline: _analyze_single_object's
empty-skeleton guard only checked skeleton.any(), which is true for a lone
pixel, so it fell through into build_vessel_graph -> skan.Skeleton(),
which requires at least one graph edge and raises a low-level scipy.sparse
ValueError ("index pointer size 0 should be 1") otherwise - the same
symptom as the fully-collapsible-junction crash fixed in PR #29, but via a
different, previously-untested path.
Replaced the three "if not skeleton.any()" guards (initial thinning,
post-junction-cleanup, post-spur-pruning) with a single
_skeleton_has_no_branches() check: true whenever every connected component
in the skeleton is a single isolated pixel, i.e. there's no possible graph
edge - a strict generalization of the all-background case, so it subsumes
the existing guards rather than adding a fourth condition alongside them.
Also adds the two categories of test coverage identified as missing
without a fix needed:
- prune_spurs's pipeline integration (spur_pruning.py's own unit tests
cover the function in isolation, but nothing exercised the repeated-
iteration loop, the graph rebuild between iterations, or the
pruned-everything-away early return at the pipeline level). Uses a
"Y of Y" fixture where removing one spur exposes a second, previously
junction-to-junction branch as a new spur only a second iteration can see.
- _iter_object_crops' bounding-box clamp, forced to actually engage by an
object whose shape touches every edge of the array.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…split
tests/test_thin_2d.py's own docstring already pointed here ("Correctness
against scikit-image's own Lee thinning is covered separately in
tests/test_2d_skimage_comparison.py"), but the file doesn't actually exist
on main - it was deleted as collateral in e0910f0 (the vesskel->maskel
rename and three-repo split) because its old version depended on the HRF
dataset loader, which moved to maskel-evaluations in that same commit.
This is a from-scratch replacement using a bundled scikit-image sample
image (skimage.data.horse(), a real non-synthetic silhouette) instead of
the HRF dataset, so it needs no external data and runs in CI exactly like
tests/test_3d_skimage_comparison.py already does. Also fixes a bug the old
version didn't have to deal with: skimage.morphology.skeletonize defaults
to Zhang's algorithm for 2D input (Lee only for 3D), so method="lee" has
to be requested explicitly for this to actually compare against the same
algorithm lee94_thin implements - a first draft of this file without that
failed with a genuine skeleton mismatch, not a false pass.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
No description provided.