I was playing around with PIL to get an appropriate palette for image display.
I discovered that if I
create a LUT (based on the DICOM spec Part 3: Section C.11.2.1.2) and map the
array pixel values
to this LUT via a Numpy piecewise function; then pass that array to PIL as an
array instead of a
buffer, I was able to get the correct palette.
This requires the DICOM image to have the Window Width and Window Center
attributes present in
the dataset. Unfortunately, the only problem is that I cannot make
"image_dfl.dcm" work with this
method. I tried implementing a fallback with the existing code, but it seems
this image does have
the Window Width/Center attributes so it uses the new code.
I attached a diff of the changes and also an image comparing the PIL version to
what OsiriX shows
using Quick Look.
I tested this on Python 2.5.4 (32-bit) on Mac OS X 10.6 using numpy 1.3.0 and
PIL 1.1.7b1.
Original issue reported on code.google.com by dicompy...@gmail.com on 14 Sep 2009 at 5:12
Original issue reported on code.google.com by
dicompy...@gmail.com
on 14 Sep 2009 at 5:12Attachments: