How to read and convert .dcm File to .png,.jpg,.gif

richieking 0 Tallied Votes 4K Views Share

This is one of the easiest steps to view and convert dcm image useing the snake(python)

There are 3 modules involved.

1. Search for pydicom and install
2. Search for matplotlib and install
3. Search for pylab and install.

If you are on ubuntu destro, Installing matplotlib via the repo will pull include the pylab. That is as far as i know. Maybe Pylab is included in matplotlib module. I stand for corrections .

Note To convert to .png,.gif,.jpg file ...

Pylab will popup the file and it will come with image as required.
Look at the statusbar and there are buttons with save disket image. Click on it then select your choice of file type to save. Make sure you save it where easy to access.

Thank you. :)

import dicom
import Image
import pylab

dFile=dicom.read_file("/home/richie/d1.dcm") #path to file
pylab.imshow(dFile.pixel_array,cmap=pylab.cm.bone) # pylab readings and conversion
pylab.show() #Dispaly
richieking 44 Master Poster

I included image module but its not active in the code.

That means i am working on image module's version.

Be a part of the DaniWeb community

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