[vtkusers] 2D XMLImage - 3D PolyData Correspondence

Luis Ibanez luis.ibanez at kitware.com
Fri Nov 9 17:29:52 EST 2007


Hi Jake,

There shouldn't be any need for a transformation between
the image and the polydata that is extracted from it.

What may be happening is that the code that you are using
for displaying the image along with the polydata is not
taking into account the image origin.

Please look at the image origing of the initial ITK image,
and compare it with the image origing of its VTK counterpart.

Then post to the list the code that you are using for
displaying the vtk image along with the polydata.

As a simple reference, you can for example display a small
sphere centered at the coordinates of the image origin as
they are reported in the ITK image.

If you don't see this sphere in the corner of the image,
then your display code is not placing the image slices
in their right position in space.

Please let us know what you find.


    Thanks


       Luis


-------------------
Jake Nickel wrote:
> I have a program that uses ITK to read in a 3D Analyze format (.hdr, 
> .img) image, uses the itkImageToVTKImageFilter, and writes two images 
> out, one using a vtkXMLImageDataWriter, and the other using a 
> vtkPolyDataWriter (after the image was passed through a 
> vtkContourFilter).  The code snippet is pasted below.
> 
> I then use another program to display these images.  The polydata is 
> surface rendered and the XML image is rendered as 3 orthogonal images 
> (transverse, sagittal, and coronal).  I have noticed that the polydata 
> (X, Y, Z) locations returned from picking do not correspond to the same 
> X, Y, Z locations in the orthogonal views.
> 
> Is there a way that I can retrieve the transformation that has taken 
> place somewhere between reading in the image and writing it back out as 
> vtkPolyData so that I have a 2D-3D correspondence?
> 
> Any help is greatly appreciated, Thanks a bunch!
> -Jake
> 
> ========================
> ...
>   typedef unsigned char PixelType;
>   const unsigned int Dimension = 3;
> 
>   typedef itk::Image< PixelType, Dimension > ImageType;
>   typedef itk::ImageFileReader< ImageType > ReaderType;
>   typedef itk::ImageToVTKImageFilter< ImageType >  ConnectorFilterType;
> 
>   ReaderType::Pointer reader  = ReaderType::New();
>   ConnectorFilterType::Pointer connector = ConnectorFilterType::New();
> 
>   reader->SetFileName( argv[1] );
>   reader->Update();
> 
>   connector->SetInput( reader->GetOutput() );
> 
>   vtkXMLImageDataWriter * writer = vtkXMLImageDataWriter::New();
>   writer->SetInput( connector->GetOutput() );
>   writer->SetFileName( argv[2] );
>   writer->Write();
>   writer->Delete();
> 
>   vtkContourFilter * filter = vtkContourFilter::New();
>   filter->SetInput( connector->GetOutput() );
>   filter->SetValue( 0, 1 );
> 
>   vtkPolyDataWriter * pwriter = vtkPolyDataWriter::New();
>   pwriter->SetFileName( argv[3] );
>   pwriter->SetInput( filter->GetOutput() );
>   pwriter->Write();
>   pwriter->Delete();
> 
>   filter->Delete();
> ...
> ========================
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list