When i load an image in VTK, convert it to mitk and convert it back, the origin gets wrong:
I have an loaded vtkImageData object:
vtkImageData* poVTKImage;
...//loading of image
//Print origin, index and size:
std::cout << "Origin: " << poVTKImage->GetOrigin()[0] << " " << poVTKImage->GetOrigin()[1] << " " << poVTKImage->GetOrigin()[2] << std::endl;
std::cout << "Index: " << poVTKImage->GetWholeExtent()[0] << " " << poVTKImage->GetWholeExtent()[2] << " " << poVTKImage->GetWholeExtent()[4] << std::endl;
std::cout << "Size: " << poVTKImage->GetWholeExtent()[1]+1 << " " << poVTKImage->GetWholeExtent()[3]+1 << " " << poVTKImage->GetWholeExtent()[5]+1 << std::endl;
//convert to mitk:
mitk::Image::Pointer oMITKImage = mitk::Image::New();
oMITKImage->Initialize(oImageReader->GetOutput()->GetImage());
oMITKImage->SetVolume(oImageReader->GetOutput()->GetImage()->GetScalarPointer());
oMITKImage->Update();
//convert back to vtk:
vtkImageData* poVTKImageFromMITKImage = oImage->GetVtkImageData();
std::cout << "Origin: " << poVTKImageFromMITKImage ->GetOrigin()[0] << " " << poVTKImageFromMITKImage ->GetOrigin()[1] << " " << poVTKImageFromMITKImage ->GetOrigin()[2] << std::endl;
std::cout << "Index: " << poVTKImageFromMITKImage ->GetWholeExtent()[0] << " " << poVTKImageFromMITKImage ->GetWholeExtent()[2] << " " << poVTKImageFromMITKImage ->GetWholeExtent()[4] << std::endl;
std::cout << "Size: " << poVTKImageFromMITKImage ->GetWholeExtent()[1]+1 << " " << poVTKImageFromMITKImage ->GetWholeExtent()[3]+1 << " " << poVTKImageFromMITKImage ->GetWholeExtent()[5]+1 << std::endl;
My cout output is:
Origin: -350.00 -358.20 -1363.50
Index: 0 0 0
Size: 512 512 181
Origin: 0.00 0.00 0.00
Index: 0 0 0
Size: 512 512 181
Origin does not match!!!!