Help with displaying dicom image using PIL

527 views
Skip to first unread message

Asritha

unread,
Dec 21, 2010, 4:07:31 PM12/21/10
to pydicom
Hi Everyone,

I have a problem displaying a dicom image properly on PIL(Python Image
Library)

I have used the code in the following link
http://code.google.com/p/pydicom/wiki/ViewingImages

but it shows some blur thing and not shows the correct image
when i open the same image in dicombrowser it displays clear image but
not with this..

Please help me..

Thanks in advance

Darcy Mason

unread,
Dec 27, 2010, 5:29:31 PM12/27/10
to pydicom
On Dec 21, 4:07 pm, Asritha <asrit...@gmail.com> wrote:
> I have a problem displaying a dicom image properly on PIL(Python Image
> Library)
>
> I have used the code in the following linkhttp://code.google.com/p/pydicom/wiki/ViewingImages
>
> but it shows some blur thing and not shows the correct image
> when i open the same image in dicombrowser it displays clear image but
> not with this..
>

That example you named is fairly basic - there is now better code in
the contrib folder [1] (pydicom_PIL.py) which includes adjusting the
window/level which might help you. The Tkinter one in the same folder
might also offer some ideas using a different display library.

[1] http://code.google.com/p/pydicom/source/browse/#hg%2Fsource%2Fdicom%2Fcontrib

Asritha

unread,
Jan 6, 2011, 7:50:36 PM1/6/11
to pydicom
I am thinking that there is a bug in the code

http://code.google.com/p/pydicom/source/browse/source/dicom/contrib/pydicom_PIL.py

In the def show_PIL
line 68 should be

if ('WindowWidth' in dataset) or ('WindowCenter' in dataset): # can
only apply LUT if these values exist

instead

if ('WindowWidth' not in dataset) or ('WindowCenter' not in dataset):
# can only apply LUT if these values exist
> [1]http://code.google.com/p/pydicom/source/browse/#hg%2Fsource%2Fdicom%2...
Reply all
Reply to author
Forward
0 new messages