Skip to content

fix: render conformant Palette Color LUTs in Advanced Blending Presentation States (#390)#391

Merged
igoroctaviano merged 6 commits into
masterfrom
fix/390-advanced-blending-lut
Jun 19, 2026
Merged

fix: render conformant Palette Color LUTs in Advanced Blending Presentation States (#390)#391
igoroctaviano merged 6 commits into
masterfrom
fix/390-advanced-blending-lut

Conversation

@igoroctaviano

Copy link
Copy Markdown
Collaborator

Summary

Fixes #390. Conformant Advanced Blending Presentation States created with highdicom (8-bit, non-segmented Palette Color LUTs) failed to render in Slim.

setPresentationState wrapped the Palette Color Lookup Table Data in new Uint16Array(...) before handing it to dicom-microscopy-viewer. But the element size of LUT data is governed by the descriptor's third value (bits per entry), not the VR. Conformant Presentation States encode 8-bit entries (descriptor [n, first, 8]) byte-packed inside the OW element, so wrapping a 256-byte LUT in a Uint16Array yielded 128 elements; DMV then rejected it (wrong number of entries) and the PR never applied.

This is the encoding @dclunie called for in #390: 8-bit, non-segmented (segmented LUTs are not allowed in Presentation State IODs). The previous viewer relied on invalid segmented [256,0,16] LUTs.

What changed

  • src/components/SlideViewer.tsx — pass Red/Green/Blue and segmented LUT data through as retrieved (no eager Uint16Array wrapping); DMV now interprets the bytes per the descriptor.
  • types/dicom-microscopy-viewer/index.d.ts — widen LUT data types to Uint8Array | Uint16Array | ArrayBuffer | number[] and fix the pre-existing Unit8Array/Unit16Array typos.

The real fix (byte reinterpretation by descriptor) lives in dicom-microscopy-viewer; see the paired PR below. Old segmented PRs still work.

Dependency

Requires dicom-microscopy-viewer with ImagingDataCommons/dicom-microscopy-viewer#246. Bump the dependency to a release that includes it.

Test plan

  • tsc --noEmit — clean.
  • biome check . — clean.
  • Reproduced the original crash with a real highdicom 5-channel Advanced Blending PR (descriptor [256, 0, 8]), then confirmed all 5 channels build and produce the expected pseudo-colors with the paired DMV fix.
  • In the app: open the monochrome CyCIF slide + its conformant Advanced Blending PR and confirm channels render and blend (no console error).
  • Confirm an old segmented-LUT PR still renders (backward compatibility).

Related

)

setPresentationState wrapped Palette Color Lookup Table Data in
`new Uint16Array(...)` before handing it to dicom-microscopy-viewer. The
element size of LUT data is governed by the descriptor's bits-per-entry, not
the VR: conformant Presentation States encode 8-bit entries (descriptor
[n, first, 8]) byte-packed inside the OW element, so eagerly wrapping in a
Uint16Array halved the entry count and made the LUT fail to apply, so the PR
never rendered.

Pass the LUT data (segmented and non-segmented) through as retrieved and let
DMV reinterpret the bytes per the descriptor. Also widen the LUT data types
in the DMV type declarations and fix the pre-existing Unit8Array/Unit16Array
typos.

Closes #390
@deepsource-io

deepsource-io Bot commented Jun 17, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 064fc12...3247ac0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 19, 2026 11:38a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@igoroctaviano igoroctaviano merged commit df7e2e3 into master Jun 19, 2026
6 of 8 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix support of Lookup Table in Advanced Blending Presentation States

1 participant