Skip to content

Conversation

@jadh4v
Copy link
Collaborator

@jadh4v jadh4v commented Nov 18, 2025

Context

Add a non-linear sigmoid grayscale colormap as an alternative to linear grayscale. This mapping is described in the DICOM standard in section C.11.2.1.3.1 SIGMOID Function and equation C.11-1. We use a normalized window_width of [-1, 1] and window_center = 0. The colormap is generated using a 16-point sampling of this function.

See: https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_c.11.2.html

## There are two ways to access the sigmoid function:
1. Developer can use the newly added sigmoid presets that already are generated on the sigmoid curve, or
2. Use the ScalarMappingMode property on vtkColorTransferFunction to adapt any color map to sigmoid mapping. the vtkColorTransferFunction provides two ScalarMappingModes. LINEAR continues to be the default value and behavior, and SIGMOID allows to switch the scalar to color mapping to the sigmoid function. Additionally, you can control the growth rate factor using setSigmoidGrowthRate() which is usually a negative number and equal to -4 according to the DICOM standard.

Results

A comparison of linear vs sigmoid grayscale using the ImageViewer example.

npm run example ImageViewer
linear sigmoid
Screenshot 2025-11-18 at 6 49 43 PM Screenshot 2025-11-18 at 6 50 00 PM

The sampled 16-point sigmoid function plotted through matplotlib:
dicom-grayscale-sigmoid-plot

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:

@jadh4v jadh4v self-assigned this Nov 19, 2025
@jadh4v jadh4v requested a review from sankhesh November 19, 2025 00:17
@jadh4v jadh4v force-pushed the ENH-add-sigmoid-interpolation-to-transfer-functions branch from 18b448d to aed71ec Compare November 19, 2025 00:18
@jadh4v
Copy link
Collaborator Author

jadh4v commented Nov 19, 2025

cc: @finetjul please also review

@jadh4v jadh4v force-pushed the ENH-add-sigmoid-interpolation-to-transfer-functions branch 2 times, most recently from 7a19880 to 12d5c65 Compare November 26, 2025 00:01
Add a non-linear sigmoid grayscale colormap as an alternative to
linear grayscale.
This mapping is described in the DICOM standard in section
C.11.2.1.3.1 SIGMOID Function and equation C.11-1.
We use a normalized window_width of [-1, 1]
and window_center = 0.
The colormap is generated using a 16-point sampling of this function.
@jadh4v jadh4v force-pushed the ENH-add-sigmoid-interpolation-to-transfer-functions branch from 12d5c65 to 879938b Compare December 12, 2025 16:17
@jadh4v jadh4v force-pushed the ENH-add-sigmoid-interpolation-to-transfer-functions branch from 879938b to 4dde193 Compare December 12, 2025 16:21
@jadh4v
Copy link
Collaborator Author

jadh4v commented Dec 12, 2025

@finetjul
I have updated this PR to drop the TransferFunction related changes. Sigmoid is now only available through the presets. Added equivalent inverted-grayscale and inverted-grayscale-DICOM-sigmoid presets. I also rebased the branch on the latest main. Should be ready to merge when ci pipeline passes.

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

@jadh4v jadh4v added this pull request to the merge queue Dec 12, 2025
Merged via the queue into Kitware:master with commit 685af96 Dec 12, 2025
2 checks passed
@github-actions
Copy link

🎉 This PR is included in version 34.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label Dec 12, 2025
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.

2 participants