[vtkusers] Problem using vtkDicomWriter

Eddy Cappeau edcpwk at gmail.com
Tue Jan 24 04:51:07 EST 2017


I'd like to use the vtkDICOMWriter class to convert a vtkImage to a set of
DICOM images.

I've compile VTK with the vtkDICOM module enabled and followed the example
from the pdf found on the github repository (

The image data is created like this :

    auto  img = vtkSmartPointer < vtkImageData >::New();
    img->SetOrigin(0, 0, 0);
    img->SetDimensions(1024, 1024, numlayer);
    img->SetSpacing(1, 1, 1);
    img->AllocateScalars(VTK_UNSIGNED_SHORT, 1);

and the data filled like this :

           for (int n = 0; x < numlayer; n++) {
                for (int x = 0; x < 1024; x++) {
                    for (int y = 0; y < 1024; y++) {
                        char* pixel =
static_cast<char*>(img->GetScalarPointer(x, y, n));
                        pixel[0] = values[x][y];

I can load the converted result with paraview without problems.
But with 3D Slicer, I can just load the first file of the serie and it
display a blank image.

What do I have to do to be able to load the images with both application ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170124/5035d6a3/attachment.html>

More information about the vtkusers mailing list