[Dcmlib] convert pixel data to numpy array

Mathieu Malaterre mathieu.malaterre at gmail.com
Sun Oct 5 12:07:53 CEST 2008


'lo,


On Sun, Oct 5, 2008 at 8:12 AM, KS Jothy <jothybasu at gmail.com> wrote:
> Hello, I have a dicom file which has pixel data with dimensions
> 512x512x3. I have used the GDCM reader to read the file, but when i
> print it shows (7fe0,0010)  ?? 1990656 Loaded:1990656. I am a newbie
> to gdcm and I don understand why it shows Loaded instead of printing.
> I want to either convert this pixeldata in to vtk format or to numpy
> array. Any help will be of great use for me

  If you have no issue with upgrading, you can just simply use the
vtkGDCMImageReader/vtkGDCMImageWriter pair available in GDCM 2.x:

http://gdcm.sourceforge.net/html/classvtkGDCMImageReader.html
and
http://gdcm.sourceforge.net/html/classvtkGDCMImageWriter.html

  For the numpy API, I guess this should be possible, see for example:

http://gdcm.svn.sf.net/viewvc/gdcm/trunk/Examples/Python/DecompressImage.py?view=markup

  The GetBuffer/GetLength is the API you are looking for. It will
gives you a nice uncompressed buffer. Hopefully numpy support creation
of array from that.

 For more info about GDCM 2.x:

http://gdcm.sourceforge.net/wiki/index.php/GDCM_Release_2.0

2cts
-- 
Mathieu



More information about the Dcmlib mailing list