Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
},
"dependencies": {
"@cornerstonejs/codec-charls": "^0.1.1",
"@cornerstonejs/codec-libjpeg-turbo-12bit": "^0.2.0",
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^0.0.7",
"@cornerstonejs/codec-openjpeg": "^0.1.0",
"dicom-parser": "^1.8.9",
Expand Down
19 changes: 14 additions & 5 deletions src/imageLoader/colorSpaceConverters/convertPALETTECOLOR.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ function convertLUTto8Bit(lut, shift) {
*
* @param {ImageFrame} imageFrame
* @param {Uint8ClampedArray} rgbaBuffer
* @returns {void}
* @returns {rgbaBuffer} as async function
*/
export default function (imageFrame, rgbaBuffer) {
export default async function (imageFrame, rgbaBuffer) {
const numPixels = imageFrame.columns * imageFrame.rows;
const pixelData = imageFrame.pixelData;
const rData = imageFrame.redPaletteColorLookupTableData;
const gData = imageFrame.greenPaletteColorLookupTableData;
const bData = imageFrame.bluePaletteColorLookupTableData;
const [rData, gData, bData] = await Promise.all([
imageFrame.redPaletteColorLookupTableData,
imageFrame.greenPaletteColorLookupTableData,
imageFrame.bluePaletteColorLookupTableData,
]);

if (!rData || !gData || !bData) {
throw new Error(`Palette data not found in ${imageFrame}`);
}

const len = imageFrame.redPaletteColorLookupTableData.length;

let palIndex = 0;
Expand Down Expand Up @@ -54,4 +61,6 @@ export default function (imageFrame, rgbaBuffer) {
rgbaBuffer[rgbaIndex++] = bDataCleaned[value];
rgbaBuffer[rgbaIndex++] = 255;
}

return rgbaBuffer;
}
2 changes: 1 addition & 1 deletion src/imageLoader/convertColorSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function convertColorSpace(imageFrame, imageData) {
} else if (imageFrame.photometricInterpretation === 'YBR_ICT') {
convertRGB(imageFrame, rgbaBuffer);
} else if (imageFrame.photometricInterpretation === 'PALETTE COLOR') {
convertPALETTECOLOR(imageFrame, rgbaBuffer);
return convertPALETTECOLOR(imageFrame, rgbaBuffer);
} else if (imageFrame.photometricInterpretation === 'YBR_FULL_422') {
convertYBRFull422ByPixel(imageFrame.pixelData, rgbaBuffer);
} else if (imageFrame.photometricInterpretation === 'YBR_FULL') {
Expand Down
Loading