[vtkusers] vtkDICOMImageReader DICOM Slice Order

David Gobbi david.gobbi at gmail.com
Mon Jun 25 19:38:25 EDT 2012


Hi Sam,

The vtkDICOMImageReader is not very flexible (and it lacks support
for compressed data, among other things).  It always flips the images
bottom-to-top (because the author preferred using bottom-to-top
ordering in VTK?) and then, in order to keep a right-handed coordinate
system for the images, it also has to set "ascending" to false.

When I use the vtkDICOMImageReader, I use the following code to
reformat the data into my desired ordering, where the images are
rasterized top-to-bottom (i.e. the first pixel in each slice is at the
upper, left corner of the image), and with the images in ascending
order:

  // the reader flips the image and reverses the ordering
  vtkSmartPointer<vtkImageReslice> flip =
    vtkSmartPointer<vtkImageReslice>::New();
  flip->SetInputConnection(reader->GetOutputPort());
  flip->SetResliceAxesDirectionCosines(
    1,0,0, 0,-1,0, 0,0,-1);
  flip->Update();

This ordering might cause problems for some people, because
vtkImageViewer and vtkImageViewer2 always expect the input images
to be rasterized bottom-to-top.  Which is why I never use vtkImageViewer
in my applications.  I prefer to use vtkImageActor instead, because it
provides more flexibility with setting the image view orientation.

 - David


On Mon, Jun 25, 2012 at 5:14 PM, Sam <sistephan at gmail.com> wrote:
> Hello,
>
> Why is the "ascending" parameter hardcoded to false?  Is there a way to
> reorder the DICOM files after I read them in?  I need the order to be
> ascending.
>
> this->AppHelper->GetImagePositionPatientFilenamePairs(sortedFiles, false);



More information about the vtkusers mailing list