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

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

Recommended Answers

All 24 Replies

Change log
1b8148505b by darcymason on Oct 10, 2008 Diff

Started dicom.image module, show_PIL()
function which uses PIL to display pixel
data. Works for CT and MR and image_defl
but needs palette adjustments. The
ExplVR_BigEndian image with RGB looks odd,
probably not being interpreted correctly.
Reorganized Dataset code to keep

This is from your link. Meaning the module is still experimental module.
Thats lower than even alpha standard.

sorry ;)

do u have any ideas? if so please let me know

I am now reading about the DICOM.

I need and hour or so. Very informative. ;)

can you provide a dicom image for me to work on? Or i can use other image type.
not sure. ;)

yeah sure but it says invalid file as the extension is .dcm

i changed the extension to .txt and uploaded but i am not sure if you change back to .dcm it works or not

I got it. wait a sec

I dont Think PIL support DICOM images.

ohk, is it possible to convert dicom pixel_data to jpeg image and then open with pil?
do u have any idea how to convert, if so please help me..

I have converted to tiff.

Its not that good. Hold on i will see if i can enhance it with Image module

Bingo. I got it. It looks like lungs i think.
They are 2. one here one there

ok cool can you please post the code..

This is my final work

import dicom
import Image

Ima=dicom.ReadFile("/home/richie/d1.dcm") # change the path

ds=Ima.InstitutionName="Any name" # not realy needed
# I just had to print this Ima.pixel_array out to show you the lists
print f # print
sa= Image.fromarray(f) ## Hear is the Image module. It needs the array method as the details from Ima. is array
if sa.show():    
   sa.save("foo.gif") # save the dat converted to gif.
print("Copy converted to file with name...[foo.gif]")

And dont forget to show some love by upvoting me ok? ;)

commented: Thanks for your help +1

when i tried it is not saving the image, i donno y
but anyways thank u for ur help

btw how to upvote?

what error??

what OS are you?

You cat take away the if statement and just leave the save. it will save in your home.
windows will be my documents i think.

no error but it is not saving the file i think as i dont find the file in serach too

Hey i got it, but the image is still blur not the actual image as when opened in dicom browser :(

I am still studying the dcm stuff.

PM me tomorrow ok .? going to bed now.

ok thanku very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.