-
-
Notifications
You must be signed in to change notification settings - Fork 400
feat(ColorMaps): Add grayscale sigmoid colormap based on DICOM standard #3365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(ColorMaps): Add grayscale sigmoid colormap based on DICOM standard #3365
Conversation
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.
18b448d to
aed71ec
Compare
|
cc: @finetjul please also review |
| -1, | ||
| 0.01798620996209156, | ||
| 0.01798620996209156, | ||
| 0.01798620996209156, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not 0 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not rely on midpoint+sharpness ?
https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/ColorTransferFunction/index.js#L721-L725
There was a problem hiding this comment.
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
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.
The sampled 16-point sigmoid function plotted through matplotlib:

Changes
PR and Code Checklist
npm run reformatto have correctly formatted codeTesting