[vtkusers] 2D XMLImage - 3D PolyData Correspondence

Jake Nickel jake.nickel at gmail.com
Wed Nov 14 18:20:49 EST 2007


Thanks for your response, Luis!  The extent of my ITK experience pretty much
boils down to using the itkImageToVTKImageFilter so that I can work with
VTK.  Therefore, I don't know how to get the initial ITK image's origin.

After my first post, I found that my PolyData is actually being flipped.  I
then found the vtkImageFlip class and that should take care of that
problem.  However, I haven't quite figured out the correspondence between
the XML image coordinates and PolyData coordinates.  It seems as though the
"3D pick position" of the PolyData = 128.8 * XML Image coordinate.  The size
of my dataset is 256 x 256 x 512 and the voxel size is just over 128.  Is
the 128 from taking the 256/2 or is it the voxel size or something else?

The code I'm using to display the vtk images is part of a much larger
program using KWWidgets, but I've pasted the essential snippets that take
care of the rendering below.

Thanks for any help!
-Jake


/* -------- PolyData -------- */
this->PolyDataRenderWidget = vtkKWRenderWidget::New();

this->PolyDataRenderWidget->SetParent( this->GetMainPanelFrame() );
this->PolyDataRenderWidget->Create();

this->PolyReader = vtkPolyDataReader::New();
this->PolyReader->SetFileName( this->polyDataFileName );

this->PolyMapper = vtkPolyDataMapper::New();
this->PolyMapper->SetInputConnection( this->PolyReader->GetOutputPort() );

this->PolyActor = vtkActor::New();
this->PolyActor->SetMapper( this->PolyMapper );

//...here I create and set a vtkInteractorStyle for the PolyDataRenderWidget

this->PolyDataRenderWidget->GetRenderer()->AddActor( this->PolyActor );
this->PolyDataRenderWidget->ResetCamera();
/* -------- end PolyData -------- */


/* -------- XML image -------- */
this->OrthoRenderWidget = vtkKWRenderWidget::New();

this->ImageViewer2 = vtkImageViewer2::New();
this->ImageViewer2->SetRenderWindow(
this->OrthoRenderWidget->GetRenderWindow() );
this->ImageViewer2->SetRenderer( this->OrthoRenderWidget->GetRenderer() );
this->ImageViewer2->SetInput( this->GetMainXMLImageReader()->GetOutput() );
this->ImageViewer2->SetupInteractor(
this->OrthoRenderWidget->GetRenderWindow()->GetInteractor() );


this->scalarRange =
this->GetMainXMLImageReader()->GetOutput()->GetScalarRange();
this->ImageViewer2->SetColorWindow( this->scalarRange[1] -
this->scalarRange[0] );
this->ImageViewer2->SetColorLevel( 0.5 * ( this->scalarRange[1] +
this->scalarRange[0] ) );

this->OrthoRenderWidget->ResetCamera();
/* -------- end XML image -------- */



On Nov 9, 2007 4:29 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071114/df5cafb5/attachment.htm>


More information about the vtkusers mailing list