suever / pydicom-experimental

pydicom test
0 stars 1 forks source link

Updated image.py to take advantage of the Window/Level included in some images to show appropriate palette #56

Closed suever closed 9 years ago

suever commented 9 years ago

From dicompy...@gmail.com on September 14, 2009 01:12:50

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.

Attachment: image.diff Screen shot 2009-09-13 at 11.44.50 PM.png

Original issue: http://code.google.com/p/pydicom/issues/detail?id=56

suever commented 9 years ago

From darcymason@gmail.com on November 22, 2009 16:14:17

Added in revision b1fbe51964 , as file pydicom_PIL.py in the contrib directory.

Status: Fixed