[vtkusers] 2D XMLImage - 3D PolyData Correspondence

Jake Nickel jake.nickel at gmail.com
Fri Oct 19 23:06:45 EDT 2007


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();
...
========================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071019/20434ece/attachment.htm>


More information about the vtkusers mailing list