Repository navigation
BUG: Seed outward march across grid-aligned zero contours - #6601
hjmjohnson merged 2 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Modules/Segmentation/LevelSets/include/itkLevelSetNeighborhoodExtractor.hxx | Updates the outside-neighbor crossing condition so exact-zero neighbors seed outside points. |
| Modules/Segmentation/LevelSets/test/CMakeLists.txt | Adds the new regression test source to the LevelSets GoogleTest driver. |
| Modules/Segmentation/LevelSets/test/itkLevelSetNeighborhoodExtractorGTest.cxx | Adds a focused regression test for outside and inside point classification around a zero contour. |
Reviews (1): Last reviewed commit: "BUG: Seed outward march across grid-alig..." | Re-trigger Greptile
85ccc9c to
5878eb8
Compare
|
A high-effort automated review found no confirmed defect in this branch (force-push = plain rebase on main). Three design-level notes for consideration: Review notes
|
CalculateDistance already treats an exact-zero pixel as inside (centerValue <= 0.0). The neighbor crossing test enforced strict inequality on both sides, so a neighbor valued at exactly zero never counted as a crossing for an outside center pixel. A pixel adjacent only to a zero-valued layer therefore queued no outward FastMarching trial point. Addresses item B21 of InsightSoftwareConsortium#6575.
Mirror the outward-march fix: an exactly-on-isovalue neighbor is a zero crossing for an inside center too, so strictly-negative pixels bordering a grid-aligned zero contour now seed the inward fast march. Without this, a narrow band that omits the exact-zero pixels leaves the inward march with no trial points, the counterpart of the outward-march bug. Adds a narrow-band regression test that excludes the exact-zero pixels from the band; it fails without either fix. Assisted-by: Claude Code — identified the asymmetric inside-march branch during review
5878eb8 to
370c55d
Compare
|
Force-push = plain rebase onto current main, folding the new GTest source into the |
LevelSetNeighborhoodExtractor::CalculateDistance()classifies an exact-zero pixel as inside but required a strict sign change to detect a crossing, so a grid-aligned zero contour seeded no outward trial points. Addresses B21 of #6575.Root cause
CalculateDistance()(itkLevelSetNeighborhoodExtractor.hxx:198-207) owns zero on the inside:but the neighbor test at
:232was strict on both sides:A neighbor valued exactly zero satisfies neither branch. An outside pixel whose only sub-zero neighbor sits on a grid-aligned zero layer therefore found no crossing in any dimension, hit the
distance == 0.0early return, and was never inserted intoOutsidePoints— the outward FastMarching pass starts from nothing. Making the outside branch non-strict (neighValue <= 0 && !inside) restores the class's own convention: zero belongs to the inside, so it is a crossing when seen from the outside.LevelSetVelocityNeighborhoodExtractorinheritsCalculateDistance()unchanged and is fixed with it.SparseFieldLevelSetImageFilter/ParallelSparseFieldLevelSetImageFilteruse a structurally different surface-interpolation test (forwardValue * centerValue < 0) — a different algorithm, not this defect.Local validation
New GoogleTest
itkLevelSetNeighborhoodExtractorGTest.cxx, registered inITKLevelSetsGTests. 5x3 image, columns x=0,1 → -1, x=2 → 0, x=3,4 → +1.SeedsOutsidePointsAcrossGridAlignedZeroContour— fail-before:OutsidePointsempty (size 0, expected 3). Pass-after: 3 points at x=3 with value 1.0, andInsidePoints= 3 points at x=2 with value 0.0.ctest -L ITKLevelSets: every test that reaches the changed code (itkLevelSetNeighborhoodExtractorTest,itkLevelSetVelocityNeighborhoodExtractorTest,itkReinitializeLevelSetImageFilterTest,itkExtensionVelocitiesImageFilterTest,itkBinaryMaskToNarrowBandPointSetFilterTest) passes, with identical results before and after.AI assistance