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

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
alphabetical.

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

sorry ;)

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

Edited 5 Years Ago by richieking: n/a

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
f=Ima.pixel_array
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? ;)

Edited 5 Years Ago by richieking: n/a

Comments
Thanks for your help

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

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.
:)

Edited 5 Years Ago by richieking: n/a

This article has been dead for over six months. Start a new discussion instead.