Skip to content

fix(colors): convert DICOM CIELab relative to the D50 white point - #655

Merged
wayfarer3130 merged 3 commits into
1.0-betafrom
fix/1.0-beta-colors-d50
Nov 24, 2026
Merged

wayfarer3130 merged 3 commits into
1.0-betafrom
fix/1.0-beta-colors-d50

Conversation

@wayfarer3130

Copy link
Copy Markdown
Contributor

Summary

This PR is the 1.0 port of #598 (commit 3843de7). Colors converts DICOM CIELab with the D50 white point, as PS3.3 C.10.7.1.1 requires. Before, the conversion used the D65 white point.

Changes

  • src/colors.js: the conversion uses the D65 sRGB matrix and a Bradford adaptation from D65 to D50. New functions: dicomlab2RGB8 and rgb82DICOMLAB. New constant: d50WhitePointXYZ. A color out of the sRGB gamut clips for each channel.
  • src/adapters/VTKjs/Segmentation.js: uses the new conversion.
  • On 1.0-beta, these two files were the same as on master before fix(colors): convert DICOM CIELab relative to the D50 white point #598. This PR takes the fix(colors): convert DICOM CIELab relative to the D50 white point #598 versions of both files with no change.
  • changelog.md: the same entry as on master. The identical text prevents a conflict when master merges into 1.0.
  • beta-1-release-notes.md: one bullet. The colors of a SEG or SR object that an older dcmjs wrote can shift. For example, a saturated blue [0, 0, 255] now displays as [91, 0, 255].
  • test/bundle-size.test.js: the ceilings increase to 1.083 (dcmjs.js) and 1.065 (dcmjs.es.js). The conversion adds about 3.5 KB.

Review

An independent review compared the port with master. src/colors.js and Segmentation.js are the same as master at 3843de7. The build exports the only Colors class from src/index.js. No package in packages/ has a second copy. The review ran the conversion in Node: the results agree with the DCMTK and PixelMed reference values within 0.0005. No function name is removed, and dicomlab2RGB still returns values from 0 to 1.

Tests

The 0.x test moves to test/issues/pr598-colors-d50.test.js.

  • On 1.0-beta without the fix, all 23 tests fail. For example: Colors.rgb82DICOMLAB is not a function.
  • After the fix, all tests pass, and the full suite passes.

The API must do this:

  • The conversions agree with the reference values, and the D50 white point maps to L = 100.

The user experience must have this:

  • A color converts to DICOM CIELab and back with no visible change, for colors in the sRGB gamut.

🤖 Generated with Claude Code

wayfarer3130 and others added 3 commits November 24, 2026 15:13
1.0 port of #598 (commit 3843de7).

src/colors.js and src/adapters/VTKjs/Segmentation.js on 1.0-beta were
the same as on master before #598, so this takes the #598 versions of
both files: sRGB -> XYZ (D65) -> Bradford -> XYZ (D50) -> CIELab and
the reverse, per channel gamut clipping, and the new dicomlab2RGB8,
rgb82DICOMLAB and d50WhitePointXYZ. The VTKjs adapter uses
dicomlab2RGB8. The changelog entry is the same as on master.

The 0.x test test/colors.test.js moves to
test/issues/pr598-colors-d50.test.js. The test file changes of #598
for readFileAsArrayBuffer were a backport from 1.0-beta and are not
needed here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Maintainer decision Q1 of the review of the 1.0 port of #598. The changelog.md entry stays as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…CIELab conversion

On the current 1.0-beta, the #598 colors code takes dcmjs.js to x1.0825 and dcmjs.es.js to x1.0649.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wayfarer3130
wayfarer3130 marked this pull request as ready for review November 24, 2026 20:28
@wayfarer3130
wayfarer3130 merged commit 9452022 into 1.0-beta Nov 24, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.17 🎉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant