You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone,
I'm looking for some pointers as I'm lost as to the root of my issue. I'm working with 8-bit RGB images, using the pixel_array to feed the image into PIL.
ds = pydicom.dcmread(file)
data = ds.pixel_array
data.shape
(438, 780, 3)
When I'm using a JPEG Lossless compressed image, I get what looks like a YBR encoded image... but it isn't YBR. However when the dcm file is decompressed using the offis dcmdjpeg first, the image displays fine. Printing the data array, the values from the jpeg lossless dcm file are certainly different than the same file that was decompressed, but the have some very strange values.
I have tried using ds.decompress() but while this does seem to do something as the TransferSyntax does change to '1.2.840.10008.1.2.1' (Explicit VR Little Endian)... the pixel_array is unchanged. And yes, I did try the convert_color_space(data, 'YBR_FULL', 'RGB') to be sure and this made things worse actually.
There was this bug report #826 which does seem to be exactly what I'm experiencing, but this looks to indicate the problem was fixed back in v1.4, so I'm lost.
I do have the latest pylibjpeg[all] installed locally from pip and I'm running pydicom v2.3.1 and PIL v8.4.0 on python v3.7.4.
Hopeful someone can point me in the right direction... Many thanks
EDIT:
Just a note... I have been able to make some progress around this, but I do think it is either a bug in pydicom or pylibjpeg. If I uninstall pylibjpeg and install python-gdcm, the pixel_array is correct. Additionally if I manually pull and parse the PixelData, I can use imagecodecs to decode the jpeg too. I'll have to try and find the pydicom calls into pylibjpeg and see if I can reproduce the issue directly to know where the bug is.
Also, I have no idea what the decompress() function is actually doing. I don't see any change to either the PixelData nor the pixel_array after calling this. I only see the TS change... 🤷♂️
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
I'm looking for some pointers as I'm lost as to the root of my issue. I'm working with 8-bit RGB images, using the pixel_array to feed the image into PIL.
So I have the data and I pass this along to PIL
When I'm using a JPEG Lossless compressed image, I get what looks like a YBR encoded image... but it isn't YBR. However when the dcm file is decompressed using the offis dcmdjpeg first, the image displays fine. Printing the data array, the values from the jpeg lossless dcm file are certainly different than the same file that was decompressed, but the have some very strange values.
I have tried using
ds.decompress()
but while this does seem to do something as the TransferSyntax does change to '1.2.840.10008.1.2.1' (Explicit VR Little Endian)... the pixel_array is unchanged. And yes, I did try theconvert_color_space(data, 'YBR_FULL', 'RGB')
to be sure and this made things worse actually.There was this bug report #826 which does seem to be exactly what I'm experiencing, but this looks to indicate the problem was fixed back in v1.4, so I'm lost.
I do have the latest pylibjpeg[all] installed locally from pip and I'm running pydicom v2.3.1 and PIL v8.4.0 on python v3.7.4.
Hopeful someone can point me in the right direction... Many thanks
EDIT:
Just a note... I have been able to make some progress around this, but I do think it is either a bug in pydicom or pylibjpeg. If I uninstall pylibjpeg and install python-gdcm, the pixel_array is correct. Additionally if I manually pull and parse the PixelData, I can use imagecodecs to decode the jpeg too. I'll have to try and find the pydicom calls into pylibjpeg and see if I can reproduce the issue directly to know where the bug is.
Also, I have no idea what the decompress() function is actually doing. I don't see any change to either the PixelData nor the pixel_array after calling this. I only see the TS change... 🤷♂️
Beta Was this translation helpful? Give feedback.
All reactions