SeiictyUsui / pydicom

Automatically exported from code.google.com/p/pydicom
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Attachments:

GoogleCodeExporter commented 9 years ago
Added in revision b1fbe51964, as file pydicom_PIL.py in the contrib directory.

Original comment by darcymason@gmail.com on 23 Nov 2009 at 12:14