Repository navigation
genseg: the clean-up, guarded by the parity tests (P5 part 2) - #1250
Merged
Merged
Conversation
…rary voxel for voxel (P5 part 1) VolumeRover's GenSeg seeded segmentation (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §5 step 1) in src/cvc/volume/segmentation/: segment.cpp's globals become genseg_context's members, its functions keep their bodies (the hand-unrolled neighbour updates included), and Segment(), GetGradient(), GetSeeds() and SearchIndex() are coroutines that yield a unit at a time. In-memory input and output: no files, no current directory. - inc/cvc/volume/segmentation.h: segment_seeded(volume, point_classes, params), segment_stepper (checking, normalising, seeding, classifying, marching, writing), segment_seeded_job (cvc::result_job), seeded_segmentation (labels, per-class volumes, border, counts, warnings). - inc/cvc/volume/segmentation_params.h: the param_table (thresholds in data units or the legacy 0..255 scale, gamma, automatic seeding, variable and timestep, class volumes). - Three fixes of the legacy code's undefined behaviour: an empty heap pop (the legacy executable crashes on such an input), a heap overflow, and a threshold sweep that ran on below 0. - tools/volrover-goldens: three more GenSeg cases that run the threshold sweep (the first three never did), with their goldens from the legacy build. - segmentation_test: T1 on all six goldens, T2-T8; in CVC_PORT_TESTS (the wasm-mt node lane) and SAN_CXX_TESTS.
docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §5 step 2, on top of part 1. The labels and border lists stay identical to the legacy library's on all six goldens, natively and under node. - GetTime() and T_GetTime(), each six hand-unrolled copies of one block (checked by script: the same block for x-1, x+1, y-1, y+1, z-1, z+1), are loops over the six face neighbours in the legacy order. - A voxel's step cost 0.01 exp(ALPHA |grad|) is computed once, not up to 36 times a pop. - The heaps hold linear indices and keep the legacy sift rules (ties decide labels where fronts meet, so the heap stays the legacy one). - The threshold sweep keeps its unclassified seeds in a vector and clears only what the last search set, instead of the linked list and InitialTime()'s flood fill from every seed. - genseg.cpp: 1,887 lines to 596. The heavy parity cases run 1.5x faster natively and 2.6x under node; about 16 bytes less per voxel.
…on says genseg.cpp and segmentation.cpp get -ffp-contract=off (/fp:precise on MSVC) like the other deterministic sources: the marches compare float arrival times, and a contracted step can flip which front wins a tie on targets with FMA (aarch64 macOS).
transfix
enabled auto-merge
November 15, 2026 04:54
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
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.
P5 part 2 of docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md (§5 step 2): the clean-up of the vendored GenSeg, guarded by part 1's parity tests.
Stacked on #1248 (part 1); review the last commit (43eff09). It touches only
src/cvc/volume/segmentation/genseg.{h,cpp}.What changes
GetTime()andT_GetTime()are each six copies of one block, one per face neighbour. A script compared the six blocks after substituting the neighbour: they are identical, in the order x-1, x+1, y-1, y+1, z-1, z+1, and the inner tests visit the neighbours of a neighbour in the same order. They are now loops over the six neighbours in that order, clamped as before (at an edge the voxel stands in for its missing neighbour).std::size_t) instead of three coordinates.InitialTime()). That cleared the same voxels, since every voxel a search sets is reached from one of its seeds through voxels it set.noisy_many_seeds, with 302 classifications, checks this.The three undefined-behaviour fixes and the other changes from part 1 stay, listed at the top of genseg.cpp. genseg.cpp goes from 1,887 lines to 596.
Measured
segmentation_testtests pass on both.RunsWhereTheLegacyLibraryCrashedtakes 1.75 s (2.7 s in part 1) and the parity test 1.7 s (2.3 s);No CI job is added or renamed. Merges on Joe's OK, after part 1.