Skip to content

Conversation

@sedghi
Copy link
Contributor

@sedghi sedghi commented Jul 24, 2024

Context

This PR introduces a new blend mode for rendering labelmaps in the Maximum Intensity Projection (MIP) mode, called MIP_LABELMAP_BLEND. This mode renders the labelmap segment edges, making them visible in the MIP rendering. It's particularly beneficial for medical imaging applications.

The new blend mode leverages the recently implemented independent components feature in the volume rendering pipeline.

Here's a comparison of labelmap rendering in MIP:

Without the new blend mode:

CleanShot 2024-07-24 at 12 01 51@2x

With the new blend mode:

CleanShot 2024-07-24 at 11 59 32@2x

The new blend mode offers more compelling information for users, similar to advanced visualization softwares. I can privately provide videos demonstrating one such software rendering the same functionality.

Results

You can run the new example below

npm run example LabelmapMIP

And you can switch between blendmodes (at line 38) to see the above effect.

The new blend mode has been tested with labelmaps, rendering labelmap segment edges visible in MIP rendering.

Key points:

  1. This blend mode only functions when:

    • The volume rendering pipeline uses independent components.
    • The labelmap is set as the second component.
  2. Algorithm overview:

    • The fragment shader samples the labelmap texture.
    • It checks if the current fragment is on a labelmap segment edge.
    • Edge fragments are rendered with a distinct color.
    • Segment outline thickness is configurable via texture.
    • The algorithm is optimized to avoid unnecessary computations for non-edge fragments.
  3. Implementation evolution:

    • Initially used a boolean array to track seen segments.
    • Encountered significant performance issues with dynamic indexing.
    • Switched to a bitmask for segment tracking, greatly improving performance.

Changes

  • A new blend mode MIP_LABELMAP_BLEND was added to the constants

  • A new path was added to the vtkVolumeFS shader to handle the new blend mode

  • 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: latest
    • OS: macOS 14.5 (23F79)
    • Browser: Version 126.0.6478.183 (Official Build) (arm64)

@finetjul
Copy link
Member

From your screen shots, it seems that the name of the mode shouldnt be labelmap_blend but more labelmap_edge or labelmap_contour. No?

@finetjul finetjul requested a review from bruyeret July 24, 2024 21:11
Copy link
Contributor

@bruyeret bruyeret left a comment

Choose a reason for hiding this comment

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

Hello, thank you for the contribution!
The rendering looks very nice
Most of my comments are about style / refactor

Copy link
Contributor

@bruyeret bruyeret left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM! @finetjul

@finetjul
Copy link
Member

That's great, thanks @sedghi .
Can you do one more thing: please add a (compressed and with similar image size ratio) screenshot (or video) in the VTK.js example galery (Documentation/content/examples/index.md)? We recently managed to be exhaustive with all our examples, let's keep it in-sync with the code !

@sedghi
Copy link
Contributor Author

sedghi commented Jul 30, 2024

@finetjul I guess i did what you requested

@finetjul
Copy link
Member

Please use this GIF instead: LabelmapEdgeProjection

@finetjul
Copy link
Member

Thanks! However, the purpose of a smaller gif is to reduce the size of the git repository, please do not create a separate commit, but squash it with the commit that introduce the gif.

@sedghi
Copy link
Contributor Author

sedghi commented Jul 30, 2024

@finetjul Done

Copy link
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

@floryst floryst added this pull request to the merge queue Aug 1, 2024
Merged via the queue into Kitware:master with commit 16c24b5 Aug 1, 2024
@github-actions
Copy link

github-actions bot commented Aug 1, 2024

🎉 This PR is included in version 31.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

4 participants