Skip to content

fix(imageResliceMapper): adjust texel size calculation for anisotropi…#3465

Merged
finetjul merged 3 commits intoKitware:masterfrom
sedghi:fix/outline-reslice-mapper
Apr 8, 2026
Merged

fix(imageResliceMapper): adjust texel size calculation for anisotropi…#3465
finetjul merged 3 commits intoKitware:masterfrom
sedghi:fix/outline-reslice-mapper

Conversation

@sedghi
Copy link
Copy Markdown
Contributor

@sedghi sedghi commented Mar 31, 2026

Context

The label-outline thickness rendered by vtkImageResliceMapper appears inconsistent (stretched or compressed) when the input image has anisotropic spacing. This
happens because the texel-size uniform used for neighbor sampling in the outline shader is computed from voxel dimensions alone, ignoring the physical spacing of
each axis.

Results

Before: outline thickness varies per axis on anisotropic data — thicker along the axis with smaller spacing, thinner along the axis with larger spacing.

After: outline thickness is visually uniform across all axes regardless of spacing differences.

CleanShot 2026-03-31 at 16 55 19@2x

Changes

  • Sources/Rendering/OpenGL/ImageResliceMapper/index.js: The texelSize uniform computation now divides by inputDims[i] * inputSpacing[i] instead of just
    inputDims[i], normalizing the texture-coordinate step by physical spacing so the outline kernel samples at consistent physical distances in all directions.

  • No API changes.

  • Documentation and TypeScript definitions were updated to match those changes

PR and Code Checklist

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

Testing

  • This change adds or fixes unit tests
  • Tested environment:
    • vtk.js:
    • OS:
    • Browser:

CC @PaulHax

@sedghi
Copy link
Copy Markdown
Contributor Author

sedghi commented Mar 31, 2026

not sure if test failing in action my fault or not, since npm test runs fine locally

Update: updated the screenshot for test

@PaulHax
Copy link
Copy Markdown
Collaborator

PaulHax commented Apr 1, 2026

Good fix.

This changes outline thickness from voxel space to physical space. The implication: small spacing produces thicker outlines, large spacing produces thinner ones for the same "outline thickness" paramter.

Current change is already better methinks, but i'm also consitering:

Normalize by the finest axis (minSpacing / (dims * spacing)) — keeps the anisotropy fix but thickness stays ~1 voxel on the finest axis.

or

Compute texelSize from the view-projection matrix so outlines are a fixed pixel width regardless of spacing or zoom

@sedghi
Copy link
Copy Markdown
Contributor Author

sedghi commented Apr 1, 2026

@PaulHax please check it out

@PaulHax
Copy link
Copy Markdown
Collaborator

PaulHax commented Apr 1, 2026

Looks good, outline thickness operating in "voxel" space makes sense to me.

@PaulHax PaulHax requested a review from sankhesh April 2, 2026 15:17
@sedghi
Copy link
Copy Markdown
Contributor Author

sedghi commented Apr 7, 2026

any chance we can merge this? @sankhesh

Copy link
Copy Markdown
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@finetjul finetjul added this pull request to the merge queue Apr 8, 2026
Merged via the queue into Kitware:master with commit ab7569c Apr 8, 2026
2 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

🎉 This PR is included in version 35.5.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released Automated label label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Automated label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants