[vtkusers] vtkDICOMImageReader origin
DVigneault
davis.vigneault at gmail.com
Mon May 11 09:11:25 EDT 2015
All--
I'm having a problem where vtkDICOMImageReader is (incorrectly) giving an
origin of zero. I have two programs (code below) to read in the image and
print out the dimension/spacing/origin--the first with ITK, the second with
VTK. The two programs give the same dimension and spacing, but the ITK
program gives a nonzero origin and the VTK program gives a zero origin. The
two programs are reading the same dataset. Am I misusing the
vtkDICOMImageReader somehow? Has anyone come across this before?
Best, and thanks,
--Davis
//
// VTK
//
#include "vtkSmartPointer.h"
#include "vtkDICOMImageReader.h"
#include "vtkImageData.h"
int main(int argc, char ** argv)
{
vtkSmartPointer< vtkDICOMImageReader > reader =
vtkSmartPointer< vtkDICOMImageReader >::New();
reader->SetDirectoryName("../../data/ct_heart");
reader->Update();
vtkSmartPointer<vtkImageData> data =
vtkSmartPointer<vtkImageData>::New();
data = reader->GetOutput();
int dims[3];
data->GetDimensions(dims);
double spacing[3];
data->GetSpacing(spacing);
double origin[3];
data->GetOrigin(origin);
std::cout << "Dimensions: [" << dims[0] << ", " << dims[1] << ", " <<
dims[2] << "]" << std::endl;
std::cout << "Spacing: [" << spacing[0] << ", " << spacing[1] << ", " <<
spacing[2] << "]" << std::endl;
std::cout << "Origin: [" << origin[0] << ", " << origin[1] << ", " <<
origin[2] << "]" << std::endl;
// Output:
// Dimensions: [512, 512, 120]
// Spacing: [0.332, 0.332, 1]
// Origin: [0, 0, 0]
return EXIT_SUCCESS;
}
//
// ITK
//
#include "itkImage.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
typedef itk::Image< short, 3 > TInImage;
typedef itk::GDCMImageIO TImageIO;
typedef itk::GDCMSeriesFileNames TImageNames;
typedef itk::ImageSeriesReader< TInImage > TImageReader;
int main( int argc, char* argv[] )
{
TImageIO::Pointer dicomIO = TImageIO::New();
TImageNames::Pointer names = TImageNames::New();
names->SetInputDirectory( "../../data/ct_heart" );
TImageReader::Pointer imageReader = TImageReader::New();
imageReader->SetImageIO( dicomIO );
imageReader->SetFileNames( names->GetInputFileNames() );
imageReader->Update();
std::cout << "Dimensions: " <<
imageReader->GetOutput()->GetLargestPossibleRegion().GetSize() << std::endl;
std::cout << "Spacing: " << imageReader->GetOutput()->GetSpacing() <<
std::endl;
std::cout << "Origin: " << imageReader->GetOutput()->GetOrigin() <<
std::endl;
// Output:
// Dimensions: [512, 512, 120]
// Spacing: [0.332, 0.332, 1]
// Origin: [-71.084, -93.584, 1562.5]
return EXIT_SUCCESS;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkDICOMImageReader-origin-tp5731878.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list