Skip to content

feat(segmentation): add the segment model, masks, algorithms and render helpers - #962

Merged
PaulHax merged 3 commits into
mainfrom
segmentation-model
Sep 30, 2026
Merged

PaulHax merged 3 commits into
mainfrom
segmentation-model

Conversation

@PaulHax

@PaulHax PaulHax commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the segmentation model and supporting operations: shared segment identity and appearance, image-scoped mask records, bounded binary storage, overlap planning and voxel access, geometry and color handling, and display and export helpers. It also provides fill-holes and Gaussian smoothing workers, segment-reference tracking, and coordination between temporary previews and committed edits.

Labelmap alignment uses the new reorientLabelImage helper through ensureSameSpace. An already aligned image is reused; equivalent grids with permuted or flipped axes are remapped with nearest-neighbor interpolation to preserve label boundaries.

Suggested reading order: src/segmentation/model.ts and segment.ts; masks/ and geometry.ts; segmentRegistry.ts, segmentReferences.ts and editing/coordinator.ts; then editing/algorithms/, rendering/, and src/io/resample/reorientLabelImage.ts.

@netlify

netlify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 772981d
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/6abbe7f12cf2370008f04a2d
😎 Deploy Preview https://deploy-preview-962--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PaulHax
PaulHax added this pull request to stack #965 September 21, 2026 20:08
…er helpers

Adds the framework-free layer of the segmentation module: the segment and mask
model, geometry helpers, colour parsing, bounded mask storage with overlap
planning and voxel access, the fill-holes and gaussian smooth algorithms with
their workers, the shared identity registry, the reference coordinator, and
the display, projection and render-mask helpers. Nothing consumes them yet;
the store, persistence, tools and UI that do follow in the next change.

Also adds reorientLabelImage, which ensureSameSpace uses to reorder an
equivalent voxel grid onto its image without interpolating label boundaries.
The label path of ensureSameSpace only skipped vtkImageReslice when the
product of the source worldToIndex and the target indexToWorld was a
bit-exact identity matrix. Real geometry never satisfies that: with an
origin and spacing such as [-120.1, -98.4, 33.7] and [0.7, 0.7, 3] the
product carries float error of about 1e-5, so a labelmap that already
sat on its parent's grid was copied through a full nearest-neighbour
reslice on the main thread, once per imported or restored mask.

The axis and eight-corner checks just above already prove the two grids
coincide within the function's 1e-3 tolerance, so the identity test now
only asks that the mapping neither permutes nor flips an axis, and the
source image is returned as-is in that case. Permuted, flipped and
genuinely different grids keep going through the reslice.
masksHolding and masksClearing.claim swept the reaching masks with
some/forEach, so every voxel a brush or polygon fill walked allocated a
fresh callback capturing i, j and k.

Both now sweep the reaching masks with a plain indexed loop, so the
per-voxel path allocates nothing. The answers are unchanged.
@PaulHax
PaulHax merged commit 805e029 into main Sep 30, 2026
7 of 8 checks passed
@PaulHax
PaulHax deleted the segmentation-model branch September 30, 2026 00:21
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