[vtkusers] vtkXMLImageDataWriter issue with image origin
From Seattle
fromseattle at gmail.com
Wed Jan 24 19:42:20 EST 2018
Hi,
I am using vtkXMLImageDataWriter to convert image file from nrrd format to
vti format. What I realized is that after conversion, the data origin is
set to (0, 0, 0), where as the original image origin is not at (0, 0, 0).
Does anyone know why it's doing that?
The following are the conversion code I used, verified that the origin
parameter is not (0, 0, 0).
typedef uint8_t AnatomyPixelType;
const unsigned int Dimension3 = 3;
typedef itk::Image<AnatomyPixelType, Dimension3> VolImageType;
itk::ImageFileReader<VolImageType>::Pointer reader =
itk::ImageFileReader<VolImageType>::New();
itk::ImageToVTKImageFilter<VolImageType>::Pointer filter =
itk::ImageToVTKImageFilter<VolImageType>::New();
vtkSmartPointer<vtkXMLImageDataWriter> writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
reader->SetFileName(fileName.c_str());
filter->SetInput(reader->GetOutput());
filter->Update();
vtkSmartPointer<vtkImageData> imageData = filter->GetOutput();
double origin[3];
imageData->GetOrigin(origin);
std::string outFileName = fileName.substr(0, fileName.length() - 5);
outFileName += ".vti";
writer->SetInputData(filter->GetOutput());
writer->SetFileName(outFileName.c_str());
writer->Write();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180124/edb0099a/attachment.html>
More information about the vtkusers
mailing list