[vtkusers] Bug in vtkImageCast

Lodron, Gerald Gerald.Lodron at joanneum.at
Wed Aug 11 10:54:48 EDT 2010


No i read it with a dicom reader, the dicom has an origin which is not 0,0,0

Here is some of my testing code:

std::cout << "VTK Checkerboard Input 1" << std::endl;
std::cout << "  Origin: " << oInput1->GetOrigin()[0] << " " << oInput1->GetOrigin()[1] << " " << oInput1->GetOrigin()[2] << std::endl;
std::cout << "  Spacing: " << oInput1->GetSpacing()[0] << " " << oInput1->GetSpacing()[1] << " " << oInput1->GetSpacing()[2] << std::endl;
//Origin is correct, spacing is correct
  
vtkSmartPointer<vtkImageCast> oInputCaster1 = vtkImageCast::New();
oInputCaster1->ReleaseDataFlagOn();
oInputCaster1->SetInput(oInput1);
oInputCaster1->SetOutputScalarTypeToShort();    
oInputCaster1->Update();

std::cout << "VTK Checkerboard Input caster 1" << std::endl;
std::cout << "  Origin: " << oInputCaster1->GetOutput()->GetOrigin()[0] << " " << oInputCaster1->GetOutput()->GetOrigin()[1] << " " << oInputCaster1->GetOutput()->GetOrigin()[2] << std::endl;
std::cout << "  Spacing: " << oInputCaster1->GetOutput()->GetSpacing()[0] << " " << oInputCaster1->GetOutput()->GetSpacing()[1] << " " << oInputCaster1->GetOutput()->GetSpacing()[2] << std::endl;
//Origin is not correct, spacing is correct
              
vtkSmartPointer<vtkImageChangeInformation> oOrigin1 = vtkImageChangeInformation::New();
oOrigin1->SetInput(oInputCaster1->GetOutput());
oOrigin1->ReleaseDataFlagOn();
oOrigin1->SetOutputOrigin(oInput1->GetOrigin());
oOrigin1->Update();
               
std::cout << "VTK Checkerboard Input origin changer 1" << std::endl;
std::cout << "  Origin: " << oOrigin1->GetOutput()->GetOrigin()[0] << " " << oOrigin1->GetOutput()->GetOrigin()[1] << " " << oOrigin1->GetOutput()->GetOrigin()[2] << std::endl;
 std::cout << "  Spacing: " << oOrigin1->GetOutput()->GetSpacing()[0] << " " << oOrigin1->GetOutput()->GetSpacing()[1] << " " << oOrigin1->GetOutput()->GetSpacing()[2] << std::endl;
//Origin is correct, spacing is correct               
       

-----Ursprüngliche Nachricht-----
Von: John Drescher [mailto:drescherjm at gmail.com] 
Gesendet: Mittwoch, 11. August 2010 16:28
An: Lodron, Gerald
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] Bug in vtkImageCast

> When i use vtkImageCast with an input image with an arbitrary origin 
> the output origin is always zero....
>

Did you change the origin anywhere in the pipeline?

John



More information about the vtkusers mailing list