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

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
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 18b448d to aed71ec Compare November 19, 2025 00:18
@jadh4v
Copy link
Collaborator Author

jadh4v commented Nov 19, 2025

cc: @finetjul please also review

-1,
0.01798620996209156,
0.01798620996209156,
0.01798620996209156,
Copy link
Member

Choose a reason for hiding this comment

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

why not 0 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I am using the equation specified by the DICOM standard:
1 / (1 + e^(4x))
The multiplying factor of 4 could be increased to make the ends closer to 0 and 1 but they are asymptotic, so they only converge to those values. I think the purpose of the sigmoid is to increase the gradient at the center of the scalar range (window). And it is probably ok to sacrifice some color range at the ends.

1,
0.9820137900379085,
0.9820137900379085,
0.9820137900379085
Copy link
Member

Choose a reason for hiding this comment

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

why not 1 ?

"RGBPoints" : [ 0, 0, 0, 0, 1, 1, 1, 1 ]
},
{
"ColorSpace" : "RGB",
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@finetjul finetjul Nov 19, 2025

Choose a reason for hiding this comment

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

Maybe add support for a "Nodes" key/value in addition to "RGBPoints".
See applyColorMap in ColorTransferFunction/index.js

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.

2 participants