Skip to content

Add hand-crafted synthetic patterns to the scikit-image equivalence tests - #42

Merged
annmoel merged 1 commit into
mainfrom
test/synthetic-thinning-equivalence
Sep 9, 2026
Merged

annmoel merged 1 commit into
mainfrom
test/synthetic-thinning-equivalence

Conversation

@annmoel

@annmoel annmoel commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Complements TestSkeletonizeComparison's single real photo (data.horse()/data.brain()) with small, deliberately-constructed patterns that each target a specific edge case from the Euler-invariant-redundancy proof in the paper's appendix, rather than relying on whatever topology happens to occur in a real image:

  • 2D (tests/test_thin_2d.py, TestSyntheticPatternEquivalence): isolated pixel, straight line, diagonal line, the minimal 2x2 checkerboard corner (the 8-vs-4-connectivity paradox), T-junction, X-junction, a ring with one real hole (Lemma 1: impossibility of hole creation), two holes separated by a single-pixel bridge (the opposite-face-neighbors configuration behind Lemma 2: impossibility of hole elimination), and a solid blob smaller than its canvas.
  • 3D (tests/test_thin_3d.py, TestSyntheticPatternEquivalence): isolated voxel, axis-aligned line, space-diagonal line (26-vs-6 connectivity analogue), a degree-6 plus-junction, and a hollow shell with one real cavity.

All 14 cases assert exact np.array_equal agreement with skimage.morphology.skeletonize(..., method="lee") - agreement only, no independent topology-invariant assertion, as discussed.

…ests

Complements TestSkeletonizeComparison's single real photo (data.horse()/
data.brain()) with small, deliberately-constructed patterns that each
target a specific edge case from the Euler-invariant-redundancy proof
rather than relying on whatever topology happens to occur in a real
image: a ring/hollow-shell (one hole/cavity to preserve, Lemma 1), two
holes separated by a single-pixel bridge (the opposite-face-neighbors
configuration behind Lemma 2), a diagonal line and a space-diagonal line
(the 8-vs-4 / 26-vs-6 connectivity paradox the border-point discussion
is built on), T/X-junctions and a 3D plus-junction (branch points), and
a solid blob smaller than its canvas.

Deliberately excluded: a volume exactly 1 voxel thick along one axis.
Investigated this directly - scikit-image's shared 3D routine
special-cases that shape (dropping to 4 border directions, treating it
as an embedded 2D image), which thin_3d does not since real 3D data is
never expected to be flat across its entire extent. Confirmed by
restricting thin_3d's own candidate/removal functions to those same 4
directions: doing so reproduces scikit-image's output exactly, so this
is a real, understood difference in scope rather than a bug - not one
thin_3d was designed to match, and documented as such in the new test
class's docstring.

All 14 new cases pass (9 in 2D, 5 in 3D); full file-scoped suite still
green (39 passed).
@annmoel
annmoel merged commit 04a2552 into main Sep 9, 2026
1 check passed
@annmoel
annmoel deleted the test/synthetic-thinning-equivalence branch September 9, 2026 06:51
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