Skip to content

feat(ImageResliceMapper): add LABELMAP_EDGE_PROJECTION_BLEND#3541

Open
sedghi wants to merge 1 commit into
Kitware:masterfrom
sedghi:feat/outline
Open

feat(ImageResliceMapper): add LABELMAP_EDGE_PROJECTION_BLEND#3541
sedghi wants to merge 1 commit into
Kitware:masterfrom
sedghi:feat/outline

Conversation

@sedghi

@sedghi sedghi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Context

This is the reslice-mapper version of the volume mapper's LABELMAP_EDGE_PROJECTION_BLEND (see the existing LabelmapEdgeProjection example): show segmentation edges over a thick-slab MIP.

Until now, useLabelOutline combined with a slab was broken — the border check compares the slab-composited center value against single-slice neighbors, so a label's entire projected footprint was painted as border.

Results

See: https://cleanshot.com/share/JSbWkTns

With a slab active:

  • Labels are projected across the slab and outlined where their projected footprint ends.
  • Each label is outlined at its own thickness.
  • Where projected labels overlap, the one nearest the camera wins (outline and fill).
  • slabThickness === 0 keeps the existing single-slice behavior.

Screenshots to be added.

New example LabelmapEdgeProjectionReslice uses the same data and spherical labels as LabelmapEdgeProjection, rendered through the reslice mapper. The slice plane follows the camera so the slab MIP can be rotated.

Changes

  • Sources/Rendering/OpenGL/ImageResliceMapper/index.js: new shader helpers (labelSlabMask, labelSlabBoxSteps, labelSlabFrontLabel) and a new fragment branch for the single-component label outline case with slabThickness > 0. MCVCMatrix is now also declared in the fragment shader for that branch.
  • Examples/Rendering/LabelmapEdgeProjectionReslice/index.js: new example.
  • Sources/Rendering/Core/ImageResliceMapper/test/testImageResliceMapperLabelOutlineSlab.js + baseline: new image test. The label spheres sit away from the slice plane, so their outlines can only come from the slab projection.

No public API changes — the feature activates from the existing useLabelOutline + slabThickness combination.

  • Documentation and TypeScript definitions were updated to match those changes (no API changes)

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • npx vitest run Sources/Rendering/Core/ImageResliceMapper/test/ — the new test plus all 7 existing reslice mapper tests pass.

  • npm run example -- LabelmapEdgeProjectionReslice — rotate the view, change the thickness and slab sliders. Slab 0 falls back to the existing path.

  • This change adds or fixes unit tests

  • Tested environment:

    • vtk.js: latest master
    • OS: macOS
    • Browser: Chrome / Chromium (vitest browser mode)

Label outline rendering on the image reslice mapper previously broke as
soon as a slab was active: the border detection compared the
slab-composited center value against single-slice neighbors, which
classified the entire projected footprint of a label as border and
painted it solid.

Labels are now projected across the slab (per-label presence bitmask
marched in texture space, clamped to the volume so arbitrarily large
slab thicknesses only cost the in-volume path) and each label is
outlined where its projected footprint ends, probed at that label's own
outline thickness. When several labels compete for a fragment, the one
nearest the viewer along the slab wins, for both outlines and fill.

Adds the LabelmapEdgeProjectionReslice example (reslice-mapper
counterpart of LabelmapEdgeProjection) and an image regression test
whose label spheres sit away from the slice plane so their outlines can
only come from the slab projection.
@sedghi

sedghi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Would you be able to review this one @bruyeret thanks!

@sedghi sedghi changed the title feat(ImageResliceMapper): add slab-projected label outline feat(ImageResliceMapper): add LABELMAP_EDGE_PROJECTION_BLEND Jul 3, 2026
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