Skip to content

Commit

Permalink
Merge pull request #11 from PantelisGeorgiadis/pgeorgiadis/htj2k
Browse files Browse the repository at this point in the history
Added support for HTJ2K syntax through OpenJPEG
  • Loading branch information
PantelisGeorgiadis authored Nov 19, 2023
2 parents e638bd0 + 978e667 commit 79e364c
Show file tree
Hide file tree
Showing 85 changed files with 228 additions and 584 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ This library was inspired by the rendering pipelines of [fo-dicom][fo-dicom-url]
- JPEG-LS Lossy Image Compression - Near-Lossless (1.2.840.10008.1.2.4.81)\*
- JPEG 2000 Image Compression - Lossless Only (1.2.840.10008.1.2.4.90)\*
- JPEG 2000 Image Compression (1.2.840.10008.1.2.4.91)\*
- High Throughput JPEG 2000 Image Compression - Lossless Only (1.2.840.10008.1.2.4.201)\*
- High Throughput JPEG 2000 with RPCL Options Image Compression - Lossless Only (1.2.840.10008.1.2.4.202)\*
- High Throughput JPEG 2000 Image Compression (1.2.840.10008.1.2.4.203)\*
--------
\*: Syntax is decoded using the native decoders WebAssembly.

Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ declare namespace TransferSyntax {
const JpegLsLossy: string;
const Jpeg2000Lossless: string;
const Jpeg2000Lossy: string;
const HtJpeg2000Lossless: string;
const HtJpeg2000LosslessRpcl: string;
const HtJpeg2000Lossy: string;
}

declare class Histogram {
Expand Down
76 changes: 38 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dcmjs-imaging",
"version": "0.1.20",
"version": "0.1.21",
"description": "DICOM image and overlay rendering for Node.js and browser using dcmjs",
"main": "build/dcmjs-imaging.min.js",
"module": "build/dcmjs-imaging.min.js",
Expand Down Expand Up @@ -44,20 +44,20 @@
"funding": "https://github.com/PantelisGeorgiadis/dcmjs-imaging?sponsor=1",
"homepage": "https://github.com/PantelisGeorgiadis/dcmjs-imaging",
"dependencies": {
"dcmjs": "^0.29.12",
"dcmjs": "^0.29.13",
"loglevel": "^1.8.1",
"loglevel-plugin-prefix": "^0.8.4"
},
"devDependencies": {
"@types/bmp-js": "^0.1.1",
"@types/bmp-js": "^0.1.2",
"bmp-js": "^0.1.0",
"browserify": "^17.0.0",
"c8": "^8.0.1",
"chai": "^4.3.10",
"clang-format": "^1.8.0",
"copy-webpack-plugin": "^11.0.0",
"docdash": "^2.0.2",
"eslint": "^8.53.0",
"eslint": "^8.54.0",
"jsdoc": "^4.0.2",
"karma": "^6.4.2",
"karma-browserify": "^8.1.0",
Expand All @@ -69,7 +69,7 @@
"mocha": "^10.2.0",
"open-cli": "^7.2.0",
"pako": "^2.1.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"shx": "^0.3.4",
"sinon": "^17.0.1",
"terser-webpack-plugin": "^5.3.9",
Expand Down
6 changes: 6 additions & 0 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const TransferSyntax = {
JpegLsLossy: '1.2.840.10008.1.2.4.81',
Jpeg2000Lossless: '1.2.840.10008.1.2.4.90',
Jpeg2000Lossy: '1.2.840.10008.1.2.4.91',
HtJpeg2000Lossless: '1.2.840.10008.1.2.4.201',
HtJpeg2000LosslessRpcl: '1.2.840.10008.1.2.4.202',
HtJpeg2000Lossy: '1.2.840.10008.1.2.4.203',
};
Object.freeze(TransferSyntax);
//#endregion
Expand All @@ -40,6 +43,9 @@ const RenderableTransferSyntaxes = [
TransferSyntax.JpegLsLossy,
TransferSyntax.Jpeg2000Lossless,
TransferSyntax.Jpeg2000Lossy,
TransferSyntax.HtJpeg2000Lossless,
TransferSyntax.HtJpeg2000LosslessRpcl,
TransferSyntax.HtJpeg2000Lossy,
];
Object.freeze(RenderableTransferSyntaxes);
//#endregion
Expand Down
8 changes: 4 additions & 4 deletions src/Lut.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,8 @@ class LutPipeline {
colorPalette !== undefined && colorPalette !== StandardColorPalette.Grayscale
? ColorPalette.getColorPaletteStandard(colorPalette)
: photometricInterpretation === PhotometricInterpretation.Monochrome1
? ColorPalette.getColorPaletteMonochrome1()
: ColorPalette.getColorPaletteMonochrome2()
? ColorPalette.getColorPaletteMonochrome1()
: ColorPalette.getColorPaletteMonochrome2()
);
pipeline.setWindowLevel(windowLevel || this._calculateWindowLevel(pixel, frame));
pipeline.setVoiLutFunction(pixel.getVoiLutFunction());
Expand Down Expand Up @@ -906,8 +906,8 @@ class LutPipeline {
frameData = pixel.hasFloatPixelData()
? pixel.getFrameDataF32(frame)
: pixel.isSigned()
? pixel.getFrameDataS32(frame)
: pixel.getFrameDataU32(frame);
? pixel.getFrameDataS32(frame)
: pixel.getFrameDataU32(frame);
} else {
throw new Error(`Unsupported pixel data value for bits stored: ${pixel.getBitsStored()}`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/NativePixelDecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ class NativePixelDecoder {
);
if (!isNodeJs) {
const response = await eval('fetch(this.webAssemblyModulePathOrUrl || wasmFilename)');
const responseArrayBuffer = await response.arrayBuffer();

return await response.arrayBuffer();
return responseArrayBuffer;
}

const fs = eval("require('fs')");
Expand Down
17 changes: 13 additions & 4 deletions src/Pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ class Pixel {
this.getTransferSyntaxUid() === TransferSyntax.Jpeg2000Lossy
) {
return NativePixelDecoder.decodeJpeg2000(this, frameFragmentsData);
} else if (
this.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000Lossless ||
this.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000LosslessRpcl ||
this.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000Lossy
) {
return NativePixelDecoder.decodeJpeg2000(this, frameFragmentsData);
}

throw new Error(
Expand Down Expand Up @@ -766,8 +772,8 @@ class PixelPipeline {
pixel.hasFloatPixelData()
? pixel.getFrameDataF32(frame)
: pixel.isSigned()
? pixel.getFrameDataS32(frame)
: pixel.getFrameDataU32(frame)
? pixel.getFrameDataS32(frame)
: pixel.getFrameDataU32(frame)
);
} else {
throw new Error(`Unsupported pixel data value for bits stored: ${pixel.getBitsStored()}`);
Expand Down Expand Up @@ -843,10 +849,13 @@ class PixelPipeline {
pixel.planarConfiguration = PlanarConfiguration.Interleaved;
}

// For color JPEG 2000 datasets, colorspace is converted to RGB in WebAssembly
// For color (HT) JPEG 2000 datasets, colorspace is converted to RGB in WebAssembly
if (
(pixel.getTransferSyntaxUid() === TransferSyntax.Jpeg2000Lossless ||
pixel.getTransferSyntaxUid() === TransferSyntax.Jpeg2000Lossy) &&
pixel.getTransferSyntaxUid() === TransferSyntax.Jpeg2000Lossy ||
pixel.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000Lossless ||
pixel.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000LosslessRpcl ||
pixel.getTransferSyntaxUid() === TransferSyntax.HtJpeg2000Lossy) &&
(pixel.getPhotometricInterpretation() === PhotometricInterpretation.YbrRct ||
pixel.getPhotometricInterpretation() === PhotometricInterpretation.YbrIct)
) {
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '0.1.20';
module.exports = '0.1.21';
Loading

0 comments on commit 79e364c

Please sign in to comment.