[vtkusers] DCMTK and VTK

Beau Sapach beau.sapach at ualberta.ca
Tue May 15 11:08:38 EDT 2007


I think there are some examples in the DCMTK forums and FAQ.

 

Here is a snippet of my code, minus the error checking and some of the image
information (dimensions, spacing, window/level, depth etc.).  It's
worthwhile to look through the DCMTK documentation, specifically the
"findAndGet" functions.  This snippet assumes the image has 16 bits per
pixel (thus the 2-byte short scalar type).

 

Beau

 

 

            //retrieve image dimensions (dimx,dimy,dimz)

            //retrieve pixel spacing (spx,spy,spz)

            //get pixel depth (depth) (DCM_BitsAllocated)

 

            //make an imagedata object

            vtkImageData * image = vtkImageData::New();

            image->SetOrigin(0,0,0);

            image->SetSpacing(spx,spy,spz);

            image->SetDimensions(dimx,dimy,dimz);

            image->SetScalarTypeToShort();

            image->AllocateScalars();

 

            //get the pointer to the allocated scalar memory from the image

            char * scalar_buf = (char*)image->GetScalarPointer();

 

            //buffer to read scalars into from dicom

            Uint8 * pUint8 = NULL;

 

            //read in the scalars

            dicom->findAndGetUint8Array(DCM_PixelData,pUint8);

 

            //since the Uint8 data gets deleted when the DcmDataset object
is destroyed

            //we have to copy the data into the buffer already allocated by
vtkImageData

            memcpy(scalar_buf,pUint8,ByteCount);

 

  _____  

From: vtkusers-bounces+beau.sapach=ualberta.ca at vtk.org
[mailto:vtkusers-bounces+beau.sapach=ualberta.ca at vtk.org] On Behalf Of Luca
Pamparana
Sent: Tuesday, May 15, 2007 8:20 AM
To: vtkusers
Subject: [vtkusers] DCMTK and VTK

 

Hi everyone,

Does anyone has any examples of reading in a DICOM volume into VTK using
DCMTK?

So, I have a list of DICOM files that comprises a volume and I want to
create a vtkImageData out of it. Does anyone know what is the best way to
achieve that? A C++ code snippet would be really nice! 

Thanks,
Luca



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070515/8b127d0e/attachment.htm>


More information about the vtkusers mailing list