New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a question about compression. #1532
Comments
You mean you try to compress data that is already compressed in another transfer syntax? You would have to decompress that first. |
I modified it with the code below, but an error occurs. ds = dcmread(filePath)
if (ds.file_meta.TransferSyntaxUID.is_compressed):
ds.decompress("pylibjpeg")
ds.compress(transferSyntax, encoding_plugin='pylibjpeg')
else:
ds.compress(transferSyntax, encoding_plugin='pylibjpeg')
ds.save_as(filePath.replace('.dcm', '') + "_" + str(transferSyntax) + ".dcm") Do you have any more code to add? |
Could you post a minimally reproducible code example and the full error traceback you're getting? It's really hard to figure out what's going on without seeing executable code (what's |
Sorry. The question was insufficient. Error code ==> ds.compress(transferSyntax, encoding_plugin='pylibjpeg') |
The error indicates that the amount of uncompressed pixel data doesn't match the expected amount, likely because the Pixel Data element itself is still compressed (which is weird, the docstring for I'd pass the uncompressed array to the compress function: ds = dcmread(...)
ds.decompress("pylibjpeg")
ds.PhotometricInterpretation = <whatever>
ds.compress(RLELossless, ds.pixel_array, encoding_plugin="pylibjpeg") Where Photometric Interpretation is probably going to either be RGB or MONOCHROME1 or 2. |
The comments were very helpful. thank you. |
A couple of reasons:
So in summary, the real reason is a lack of third-party support for DICOM conformant JPEG encoding. |
I am using pydicom version 2.2.2.
I tried DICOM compression by referring to Compressing Pixel Data in the pydicom User Guide.
Implicit Little Endian and Explicit Little Endian compressed well, as described in the guide.
However, in compressed DICOM such as J2K, an error occurs during the compression process.
The text was updated successfully, but these errors were encountered: