Skip to content

segment.critical-points, cvc segment --automatic critical-points, pycvc critical_point_seeds, and VolUtils' seed generators (P6 part 2) - #1292

Merged
transfix merged 10 commits into
masterfrom
p6/paper-mode-surfaces
Nov 17, 2026
Merged

transfix merged 10 commits into
masterfrom
p6/paper-mode-surfaces

Conversation

@transfix

Copy link
Copy Markdown
Owner

P6 part 2 of docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md (§5 steps 3-4): the surfaces of the paper's automatic seeding, plus the seed generators from VolUtils (#123).

Stacked on part 1 (#1291). Until that PR lands, this diff includes part 1's commits. After it lands, origin/master will be merged in here, and the diff will be this part's changes alone. Please review it after that.

What lands

  • DSL: segment.critical-points, with -async and -start.
    • It runs cvc::critical_point_seeds behind the generic job forms of cvc/core/job_intrinsics.h.
    • It is registered next to segment.seeded (critical_point_seeds_op, key cvc.segment).
    • The result is a point_classes data object with the classes feature and background.
    • segment.seeded with "automatic" "critical_points" accepts empty classes.
  • CLI:
    • cvc segment --automatic critical-points (or critical_points) runs with no seeds file. The --cp-* flags come from the parameter table.
    • New commands cvc capsid-seeds and cvc rotate-seeds write point classes. rotate-seeds --from cut.rawiv rotates seeds marked on a cut of the volume into the whole volume, as SeedProduce did.
  • pycvc:
    • functions critical_point_seeds(vol, **kw), critical_point_seeds_job, capsid_critical_points and rotated_seeds;
    • parameter classes capsid_seed_params and rotation_seed_params;
    • the diffusion types from gradient_vector_diffusion.h.
  • Seed generators (inc/cvc/volume/seed_generators.h, with tables in seed_generators_params.h). The sources are cvc-cli: absorb remaining VolUtils capabilities (from closed volrover#4 salvage audit) #123's VolUtils at volrover edabb85^.
    • cvc::capsid_critical_points ports criticalPntsToSeed and SegSubunit's FindCriticalPoints. It keeps the bright local maxima the capsid's T-number calls for, plus the gradient magnitude's maxima when those are few. It is a sliced stepper (checking, normalising, maxima, saddles) with a job.
    • cvc::rotated_seeds ports SeedProduce and SeedProduceRegardingAxis: N-fold rotational copies of seeds about an axis, each landing on the nearest voxel of the target volume. Class n holds the n-th rotation, named Class n in the legacy colours.

Tests (§1.7 rows)

  • T10, segmentation_intrinsics_test (cooperative and threaded): CriticalPointsInTheThreeForms (plain, -async, -start) and SegmentSeededWithCriticalPointsNeedsNoClasses.

  • T11, test_pycvc_segmentation.py: test_the_papers_automatic_mode and test_the_seed_generators.

  • T12, cvc_cli_test: SegmentAutomaticCriticalPointsNeedsNoSeeds and CapsidSeedsAndRotateSeeds.

  • seed_generators_test (new, 10 tests):

    • the legacy definitions: capsid maxima, the T-number count, data-unit thresholds;
    • rotations about the volume's axis, about any axis, and from a cut;
    • bad input, the stepper under T7's harness, calls on separate threads, the tables.

    There is no T1 for the seed generators: VolUtils left volrover's master (app: use this->uniqueThreadKey() inside startThread<T> (no singleton self-reach) #19, edabb85) before the commit the goldens are pinned to.

seed_generators_test is in port_tests.cmake and SAN_CXX_TESTS. No CI job is added or renamed. ci.yml changes on one line and keeps its CRLF line endings.

Legacy bugs not ported

  • SeedProduceRegardingAxis added y into the axis centre's z.
  • SeedProduce used pi = 3.1415926 and rounded with (int)(x + 0.5), which is wrong for negative x. The port uses the exact pi and floor(x + 0.5).

Rules

  • No singletons: tools/singleton_scan is unchanged, with no allowlist line.
  • No GPL code: VolUtils is CVC's own code.
  • git-clang-format was run on the changed lines only.

Refs #123.

…adient_vector_diffusion, seed_mode::critical_points, critical_point_seeds

Phase P6 of docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md (§5 steps 3-4), the core:

- cvc::gradient_vector_diffusion (inc/cvc/volume/gradient_vector_diffusion.h): SegMed's gvfflow
  (Eqs. 2-3 of Bajaj, Yu and Auer 2003) as a sliced stepper, a voxel update per unit, with its job
  and parameter table; the weighing field is a parameter (the field being diffused, the paper's
  and SecStruct's, or the initial one, SegMed's). cvc::critical_point_at classifies a voxel of a
  field by SegMed's 26-neighbour test. Shared, for SecStruct, SegMonomer and the §2.3 skeletons.
- seed_mode::critical_points: the critical points of the diffused gradient field as two classes
  after the point classes, "feature" (maxima) and "background" (minima), with the paper's §4
  thresholds (cp_feature_threshold, cp_background_threshold) and SegMed's choices as parameters
  (cp_field, cp_weights, cp_sample). They are seeded in genseg_context's "seeding" phase, before
  the user's seeds (which win a shared voxel); the point classes may be empty. The default stays
  local_maxima (§5 step 5 switches it later).
- cvc::critical_point_seeds, critical_point_seeds_stepper and critical_point_seeds_job.
- param_table: enum names also read with '-' for '_' (critical-points).
- SegMed audit in the roadmap's §1.3 table: GVF_Compute returns at GVF.cpp:97, so its diffusion
  and critical points never ran; Segment marches from 13 seeds hard-coded for one heart dataset.
- tools/volrover-goldens: a segmed library (the dead code built with the early return patched
  out), four cases, goldens of the critical list and the diffused field.

Tests (port_tests.cmake and SAN_CXX_TESTS): gradient_vector_diffusion_test (T2-T8) and
critical_points_test (T1: the field bit for bit and the critical lists point for point against
SegMed on all four cases; T3-T8). segmentation_test's six GenSeg goldens still match.
…vc critical_point_seeds, and VolUtils' seed generators (P6 part 2)

Phase P6 of docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md, the surfaces (§5 steps 3-4), on top of
part 1:

- DSL: segment.critical-points (+ -async / -start), cvc::critical_point_seeds behind the generic
  job forms of cvc/core/job_intrinsics.h, registered beside segment.seeded (critical_point_seeds_op,
  key cvc.segment); the result is a point_classes data object (feature, background). segment.seeded
  with "automatic" "critical_points" takes empty classes.
- CLI: cvc segment --automatic critical-points (or critical_points) runs with no seeds file; the
  --cp-* flags come from the table. cvc capsid-seeds and cvc rotate-seeds write point classes.
- pycvc: critical_point_seeds(vol, **kw), critical_point_seeds_job, capsid_critical_points,
  rotated_seeds, and the capsid_seed_params / rotation_seed_params classes.
- Seed generators (#123's VolUtils leftovers; sources at volrover edabb85^):
  cvc::capsid_critical_points (criticalPntsToSeed, SegSubunit's FindCriticalPoints: maxima kept for
  the capsid's T-number, plus the gradient magnitude's maxima when they are few), a sliced stepper
  with its job; cvc::rotated_seeds (SeedProduce, SeedProduceRegardingAxis: N-fold rotational copies
  about an axis), inc/cvc/volume/seed_generators.h with parameter tables.

Tests: segmentation_intrinsics_test (T10: segment.critical-points in its three forms, cooperative
and threaded; segment.seeded with no classes), cvc_cli_test (T12: SegmentAutomaticCriticalPoints*,
CapsidSeedsAndRotateSeeds), test_pycvc_segmentation.py (T11), seed_generators_test (new, in the ports
lane and SAN_CXX_TESTS: the legacy definitions, the stepper, threads, tables; no T1, as VolUtils
left volrover's master before the pinned commit).
# Conflicts:
#	bindings/pycvc/pycvc_jobs.i
…s hidden until part 2

pycvc's %include of segmentation.h wrapped critical_point_seeds_job, whose
result_job<point_classes> SWIG could not name, and seeded_segmentation_params'
cp_weights, a diffusion_weights it knew nothing of. GCC and clang (tsan, ariglx-web)
failed on the generated code. pycvc_segmentation.i now includes
gradient_vector_diffusion.h for its enums and ignores critical_point_seeds, its stepper
and its job; part 2 wraps them.
# Conflicts:
#	bindings/pycvc/pycvc_segmentation.i
# Conflicts:
#	src/cvc/tests/port_tests.cmake
@transfix
transfix merged commit 4268c0e into master Nov 17, 2026
29 checks passed
@transfix
transfix deleted the p6/paper-mode-surfaces branch November 17, 2026 07:21
transfix added a commit that referenced this pull request Nov 17, 2026
One conflict, in ci.yml's SAN_CXX_TESTS: this branch added stream_test, net_ws_client_test and
ariadne_host_test to the sanitizer legs' list, and #1292 added gradient_vector_diffusion_test,
critical_points_test and seed_generators_test (reflowing the lines). Kept both.

ci.yml's line 1271 (the arigl-web path filter's files.h/files.cpp line) also goes back to master's
bytes: master stores ci.yml with CRLF but that one line LF-only, and an earlier merge here had
given it a CR, a whitespace-only change in this PR's diff.
transfix added a commit that referenced this pull request Nov 20, 2026
P6 moved segment_seeded's input read into genseg::read_voxels (critical_points.cpp), which
segment_seeded, critical_point_seeds and capsid_critical_points share. The threaded read moves
there with it: read_voxels hands the context the app's compute pool once the volume holds two
pieces, and reads in pieces (the first non-finite voxel still the first in order, the same
messages). genseg.cpp keeps both includes; segmentation_test keeps GroELAsTheLegacyLibrary next
to #1303's real-map tests.
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