From b852240378390237db42cf2497bc953734410c3e Mon Sep 17 00:00:00 2001 From: CIick Date: Mon, 29 Jun 2026 15:44:11 -0400 Subject: [PATCH] fix(dicomImageLoader): reset planarConfiguration to 0 after JPEG Lossless decode jpeg-lossless-decoder-js always outputs pixel-interleaved data (RGBRGB...) regardless of the DICOM Planar Configuration tag (0028,0006). When that tag is 1 (band-interleaved), downstream convertColorSpace incorrectly calls convertRGBColorByPlane on interleaved data, producing severe rainbow color artifacts on RGB images encoded with transfer syntaxes 1.2.840.10008.1.2.4.57 and 1.2.840.10008.1.2.4.70. The same issue almost certainly exists in decodeJPEGLS, decodeJPEG2000, and decodeHTJ2K, which likewise do not reset planarConfiguration after decoding. This was confirmed for decodeJPEG2000: manually setting planarConfiguration=1 on a JPEG 2000 RGB image reproduced the same rainbow artifacts. Those decoders are not changed here as test images directly from the modality were not obtained to verify the fix end-to-end. --- .../dicomImageLoader/src/shared/decoders/decodeJPEGLossless.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/dicomImageLoader/src/shared/decoders/decodeJPEGLossless.ts b/packages/dicomImageLoader/src/shared/decoders/decodeJPEGLossless.ts index 69fdc88a68..667917b2c9 100644 --- a/packages/dicomImageLoader/src/shared/decoders/decodeJPEGLossless.ts +++ b/packages/dicomImageLoader/src/shared/decoders/decodeJPEGLossless.ts @@ -47,6 +47,8 @@ async function decodeJPEGLossless( byteOutput ); + imageFrame.planarConfiguration = 0; + if (imageFrame.pixelRepresentation === 0) { if (imageFrame.bitsAllocated === 16) { imageFrame.pixelData = new Uint16Array(decompressedData.buffer);