<div dir="ltr">Hi Davis,<div><br></div><div>The vtkDICOMImageReader doesn't set the Origin.  In any case, the VTK "Origin" and the ITK "Origin" have slightly different definitions, because in ITK the origin takes the image orientation into account.</div><div><br></div><div>The best you can do is call GetImagePositionPatient() and GetImageOrientationPatient() on the reader, and use the results to position and orient the image.</div><div><br></div><div>I've written my own dicom reader (<a href="https://github.com/dgobbi/vtk-dicom">https://github.com/dgobbi/vtk-dicom</a>) that provides a GetPatientMatrix() method to return the position/orientation as a vtkMatrix4x4.</div><div><br></div><div> - David<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 11, 2015 at 7:11 AM, DVigneault <span dir="ltr"><<a href="mailto:davis.vigneault@gmail.com" target="_blank">davis.vigneault@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">All--<br>
<br>
I'm having a problem where vtkDICOMImageReader is (incorrectly) giving an<br>
origin of zero.  I have two programs (code below) to read in the image and<br>
print out the dimension/spacing/origin--the first with ITK, the second with<br>
VTK.  The two programs give the same dimension and spacing, but the ITK<br>
program gives a nonzero origin and the VTK program gives a zero origin. The<br>
two programs are reading the same dataset.  Am I misusing the<br>
vtkDICOMImageReader somehow?  Has anyone come across this before?<br>
<br>
Best, and thanks,<br>
<br>
--Davis<br>
<br>
//<br>
// VTK<br>
//<br>
<br>
#include "vtkSmartPointer.h"<br>
#include "vtkDICOMImageReader.h"<br>
#include "vtkImageData.h"<br>
<br>
int main(int argc, char ** argv)<br>
{<br>
<br>
  vtkSmartPointer< vtkDICOMImageReader > reader =<br>
    vtkSmartPointer< vtkDICOMImageReader >::New();<br>
  reader->SetDirectoryName("../../data/ct_heart");<br>
  reader->Update();<br>
<br>
  vtkSmartPointer<vtkImageData> data =<br>
    vtkSmartPointer<vtkImageData>::New();<br>
  data = reader->GetOutput();<br>
<br>
  int dims[3];<br>
  data->GetDimensions(dims);<br>
<br>
  double spacing[3];<br>
  data->GetSpacing(spacing);<br>
<br>
  double origin[3];<br>
  data->GetOrigin(origin);<br>
<br>
  std::cout << "Dimensions: [" << dims[0] << ", " << dims[1] << ", " <<<br>
dims[2] << "]" << std::endl;<br>
  std::cout << "Spacing: [" << spacing[0] << ", " << spacing[1] << ", " <<<br>
spacing[2] << "]" << std::endl;<br>
  std::cout << "Origin: [" << origin[0] << ", " << origin[1] << ", " <<<br>
origin[2] << "]" << std::endl;<br>
<br>
// Output:<br>
// Dimensions: [512, 512, 120]<br>
// Spacing: [0.332, 0.332, 1]<br>
// Origin: [0, 0, 0]<br>
<br>
<br>
  return EXIT_SUCCESS;<br>
}<br>
<br>
//<br>
// ITK<br>
//<br>
<br>
#include "itkImage.h"<br>
#include "itkGDCMImageIO.h"<br>
#include "itkGDCMSeriesFileNames.h"<br>
#include "itkImageSeriesReader.h"<br>
<br>
typedef itk::Image< short, 3 >   TInImage;<br>
typedef itk::GDCMImageIO                              TImageIO;<br>
typedef itk::GDCMSeriesFileNames                      TImageNames;<br>
typedef itk::ImageSeriesReader< TInImage >            TImageReader;<br>
<br>
int main( int argc, char* argv[] )<br>
{<br>
<br>
  TImageIO::Pointer dicomIO = TImageIO::New();<br>
<br>
  TImageNames::Pointer names = TImageNames::New();<br>
  names->SetInputDirectory( "../../data/ct_heart" );<br>
<br>
  TImageReader::Pointer imageReader = TImageReader::New();<br>
  imageReader->SetImageIO( dicomIO );<br>
  imageReader->SetFileNames( names->GetInputFileNames() );<br>
  imageReader->Update();<br>
<br>
  std::cout << "Dimensions: " <<<br>
imageReader->GetOutput()->GetLargestPossibleRegion().GetSize() << std::endl;<br>
  std::cout << "Spacing: " << imageReader->GetOutput()->GetSpacing() <<<br>
std::endl;<br>
  std::cout << "Origin: " << imageReader->GetOutput()->GetOrigin() <<<br>
std::endl;<br>
<br>
// Output:<br>
// Dimensions: [512, 512, 120]<br>
// Spacing: [0.332, 0.332, 1]<br>
// Origin: [-71.084, -93.584, 1562.5]<br>
<br>
  return EXIT_SUCCESS;<br>
<br>
}<br>
</blockquote></div><br></div></div></div>