feat(ImageResliceMapper): add LABELMAP_EDGE_PROJECTION_BLEND#3541
Conversation
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.
|
Would you be able to review this one @bruyeret thanks! |
The slab sampling loop marched slabThickness / (0.5 * minSpacing) iterations per fragment regardless of the volume bounds, so slab thicknesses much larger than the volume (whole-volume projections) spent almost all iterations sampling nothing. Track when each march direction leaves the unit texture cube - sample positions advance monotonically along a line and the cube is convex, so an exited direction can never re-enter - and stop the loop once both have exited. The cost is now proportional to the in-volume portion of the slab.
…er pass postambles The slab label outline fragment block returned early for transparent, edge, and fill fragments. Render passes append code after the mapper's fragment block - the order-independent translucency pass premultiplies gl_FragData[0] by a depth weight and writes that weight to a second render target - so returning early left those outputs unwritten and corrupted the pass's resolve (outlines composited washed-out/white under a translucent pass). Restructure the block to assign gl_FragData[0] exactly once and fall through; transparent fragments now exit through the pass's own zero-alpha discard.
|
I did not do a full review, but looking at the shader part it looks good to me 👍 |
|
@sankhesh would you be able to review this one? thanks |
|
Thanks guys, @finetjul PR seems ready for your review/merge |
finetjul
left a comment
There was a problem hiding this comment.
LGTM.
Examples now require an illustring image. Please add a screenshot named LabelmapEdgeProjectReslice.png or .jpg in Documentation/public/gallery. It should work out of the box.
Thanks.
|
Done — added a gallery screenshot for the example. Note it's named |
|
🎉 This PR is included in version 36.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Context
This is the reslice-mapper version of the volume mapper's
LABELMAP_EDGE_PROJECTION_BLEND(see the existingLabelmapEdgeProjectionexample): show segmentation edges over a thick-slab MIP.Until now,
useLabelOutlinecombined 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:
slabThickness === 0keeps the existing single-slice behavior.Screenshots to be added.
New example
LabelmapEdgeProjectionResliceuses the same data and spherical labels asLabelmapEdgeProjection, 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 withslabThickness > 0.MCVCMatrixis 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+slabThicknesscombination.PR and Code Checklist
npm run reformatto have correctly formatted codeTesting
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: