pydicom / pydicom

Read, modify and write DICOM files with python code

Home Page:https://pydicom.github.io/pydicom/dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decompress JPEG Baseline (Process 1)

opennog opened this issue · comments

Describe the bug
The decompress() method seems not to be working with this data with image-00000.dcm included in the attached zip file. This is the original file that that I want to transform to Explicit VR Little Endian. If I use the pydicom.decompressed method the resulting image looks like:
image-00000_1

while if I use dcmdjpeg the image is like:
image-00000_2

It seems like the decompression was not done correctly.
dicom_files.zip
5:59)

Your environment
$ python -m pydicom.env_info

module version
platform Linux-5.4.0-1087-gcp-x86_64-with-glibc2.31
Python 3.9.12
[GCC 10.3.0]
pydicom 2.3.0
gdcm 3.0.22
jpeg_ls cannot determine version
numpy 1.22.2
PIL 9.1.1
pylibjpeg 1.4.0
openjpeg 1.3.2
libjpeg 1.3.4

The following works fine for me with GDCM, which should be the first handler you're using:

from pydicom import dcmread
from pydicom.pixel_data_handlers import convert_color_space

import matplotlib.pyplot as plt

ds = dcmread("image-00000.dcm")
ds.decompress()
rgb = convert_color_space(ds.pixel_array, "YBR_FULL", "RGB")

plot = plt.imshow(rgb)
plt.show()

@opennog did you resolve your issue?