cornerstonejs / dicomParser

JavaScript parser for DICOM Part 10 data
MIT License
712 stars 228 forks source link

Reading JPEG2000Loseless data #264

Open syedkibrahim opened 8 months ago

syedkibrahim commented 8 months ago

We are trying to read a 16-bit JPEG2000Loseless type (Transfer Syntax ID - 1.2.840.10008.1.2.4.90).

Using DicomParser we saw that this file is having encapsulatedPixelData: true. 294477784-ecc4e4eb-1156-4e43-aa08-ba498ef68a89

Is there any way we can determine if the arrayBuffer contains compressed data or decompressed data ? And if it is compressed data then is there a method to decompress it before proceeding further ?

Any inputs or help will be really appreciated, thanks.

yagni commented 8 months ago

It's compressed since it has the transfer syntax UID you listed (otherwise it would have one of the more traditional transfer syntaxes, like explicit VR little endian).

As far as decompressing goes, you'll need to find another library to do JPEG2000 decompression for you. Each fragment in your dicomParser dataset has a position and a length; you can pass the range of bytes defined by those numbers to the JPEG2000 library to decompress (here's a StackOverflow that might help). If you have multiple fragments, you'll need to recombine them after decompressing each one individually.