Skip to content

cvc segment, pycvc.segment_seeded and segment.seeded (P5 part 3) - #1252

Merged
transfix merged 4 commits into
masterfrom
p5/genseg-surfaces
Nov 16, 2026
Merged

transfix merged 4 commits into
masterfrom
p5/genseg-surfaces

Conversation

@transfix

Copy link
Copy Markdown
Owner

P5 part 3 of docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md: the surfaces of the GenSeg port. These are cvc segment, pycvc, and segment.seeded with its -async and -start forms (§1.4, §1.6, §5).

Stacked on #1248 (part 1); review the last commit (809dcc1). It doesn't depend on part 2 (#1250, the clean-up). The two touch different files and merge in either order.

DSL: segment.seeded (T10)

inc/cvc/volume/segmentation_intrinsics.h registers the op through the generic job forms of cvc/core/job_intrinsics.h (P0b):

(segment.seeded vol classes [params])            ; waits on the job
(segment.seeded-async vol classes [params])      ; a future
(segment.seeded-start vol classes [params] target) ; the pid at once; node keys under target,
                                                 ; the result at target.result
  • Inputs. vol is a cvc::volume and classes a cvc::point_classes, each a data object or a state path to a node's data channel. params is a dict of the table's fields; (params.defaults "segment.seeded") lists them.
  • Result. A dict:
    • labels: a data object holding the UChar volume;
    • classes: a list of volume data objects;
    • border: a point_classes with one class, "border", so point-classes.points reads it;
    • class_names, class_voxels, automatic_seeds, classified_seeds, the normalised thresholds and warnings.
  • No files. Like every intrinsic (Joe, 2026-11-12), it reads and writes none.
  • Hosts. install_segmentation_intrinsics(app) adds it to one app's Ariadne lanes (key cvc.segment), as P0d's installers do.
  • Tests. segmentation_intrinsics_test, in CVC_PORT_TESTS (the wasm-mt node lane) and SAN_CXX_TESTS:
    • the three forms, cooperative and threaded;
    • a bad parameter and a bad input raising at the call;
    • params.defaults;
    • job.cancel and a kill part-way through;
    • an Ariadne button running segment.seeded-start under the default action limits, the frames continuing while it runs (160³), its progress keys rising, and the result landing at target.result.

CLI: cvc segment (T12)

cvc segment map.rawiv --seeds classes.vgr --tlow 40 --thigh 200 -o labels.rawiv
cvc segment map.mrc --seed virus:40,40,40 --seed solvent:2,2,2 --t-low 0.1 --t-high 0.8 -o labels.rawiv
  • Flags. They come from the param table (--t-low, --t-high, --normalized-thresholds, --gamma, --automatic, --variable, --timestep, --class-volumes). The legacy --tlow / --thigh take VolumeGridRover's integers on the 0..255 scale and turn on --normalized-thresholds.
  • Seeds. From a point-class file (--seeds, .vgr or .pts; a .pts file gets the volume's grid) or from --seed name:i,j,k.
  • Outputs. The labels go to -o, the class volumes to <stem>_class_NN<ext>, and the border voxels to --border file as "i j k" lines. --seconds n reports progress.
  • Tests. cvc_cli_test's Segment*: help, two blobs with every output read back, the legacy flags with a .vgr file, and bad input (no seeds, a seed outside, a bad gamma, a malformed --seed).

pycvc (T11)

bindings/pycvc/pycvc_segmentation.i wraps the header:

  • pycvc.segment_seeded(vol, seeds, t_low=..., automatic="none", ...) takes keywords from the table; an enum can be given by name. The GIL is released during the call.
  • The result has labels_array(), a zero-copy uint8 numpy view, plus labels, classes (volumes sharing their voxels), class_names, class_voxels, border_array() and warnings.
  • pycvc.segment_seeded_job is the job, through the generic PYCVC_RESULT_JOB. Bad input raises ValueError.
  • test_pycvc_segmentation.py covers keywords and the params class, the numpy views, another thread ticking during a call, bad input, and the job's steps and cancel. The browser pycvc builds from the same pycvc.i.

Checked locally

  • Natively (MSVC): segmentation_test (18), segmentation_intrinsics_test (9), cvc_cli_test --gtest_filter=*Segment* (4) and ctest pycvc_segmentation all pass.
  • Under node (wasm-mt): segmentation_intrinsics_test passes (9).

Notes

Merges on Joe's OK, after part 1.

The surfaces of the GenSeg port (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §1.4, §1.6, §5),
on top of part 1.

- segment.seeded with its -async and -start forms through cvc/core/job_intrinsics.h
  (inc/cvc/volume/segmentation_intrinsics.h): inputs a volume and point classes, each a data
  object or a state path; the result dict holds the labels and class volumes as data objects,
  the border as point classes, the names, counts and warnings. install_segmentation_intrinsics
  adds it to one app's Ariadne lanes. segmentation_intrinsics_test (T10) in CVC_PORT_TESTS and
  SAN_CXX_TESTS.
- cvc segment: flags from the param table, --seeds (.vgr/.pts) or --seed name:i,j,k, the legacy
  --tlow / --thigh on the 0..255 scale; writes the labels, <stem>_class_NN<ext> and --border.
  cvc_cli_test's Segment* tests (T12).
- pycvc: segment_seeded with keywords (an enum by name), the result with a zero-copy uint8 view
  of the labels, class volumes and a border array; segment_seeded_job (pycvc_jobs.i);
  test_pycvc_segmentation.py (T11).
@transfix
transfix enabled auto-merge November 15, 2026 04:54
#1171 (P1 part 3: skeleton.compute, cvc skeleton, pycvc) added its job to pycvc_jobs.i and its
CLI tests to cvc_cli_test.cpp where this branch adds segment_seeded_job and the cvc segment
tests. Both kept, segmentation first.
Master now has P5 parts 1 and 2 (#1248 and #1250, the GenSeg core and its clean-up), the
4.0.0 bump (#1221), live textures (#1236) and Ewave's timeout (#1261). No conflicts: this
branch's CLI, pycvc and DSL sit on the cleaned-up genseg.cpp unchanged.
@transfix
transfix merged commit f2593e7 into master Nov 16, 2026
28 checks passed
@transfix
transfix deleted the p5/genseg-surfaces branch November 16, 2026 01:02
transfix added a commit that referenced this pull request Nov 16, 2026
…#1253, #1255, #1256, #1264, #1268, #1271, #1273, #1277)

- ci.yml: the sanitizer list keeps this branch's tests (stream_test, net_ws_client_test,
  ariadne_host_test) and master's segmentation_intrinsics_test.
- STATE_EXEC_THREADED.md: the room-call verbs (room-run is #1273's) and #1252's segment.seeded
  provider in the provider table, both registered without a kind. room-call's async functions
  stay on the app's host: a reply settles on the relay client's reader thread through
  host.finish, so moving them to *ictx.host needs a finisher first.
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