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.
<br><br>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? <br>
<br>
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.<br><br>Thanks for any help!<br>-Jake<br><br><br>/* -------- PolyData -------- */<br>this->PolyDataRenderWidget = vtkKWRenderWidget::New();<br><br>this->PolyDataRenderWidget->SetParent( this->GetMainPanelFrame() );
<br>this->PolyDataRenderWidget->Create();<br><br>this->PolyReader = vtkPolyDataReader::New();<br>this->PolyReader->SetFileName( this->polyDataFileName );<br><br>this->PolyMapper = vtkPolyDataMapper::New();
<br>this->PolyMapper->SetInputConnection( this->PolyReader->GetOutputPort() );<br><br>this->PolyActor = vtkActor::New();<br>this->PolyActor->SetMapper( this->PolyMapper );<br><br>//...here I create and set a vtkInteractorStyle for the PolyDataRenderWidget
<br><br>this->PolyDataRenderWidget->GetRenderer()->AddActor( this->PolyActor );<br>this->PolyDataRenderWidget->ResetCamera();<br>/* -------- end PolyData -------- */<br><br><br>
/* -------- XML image -------- */<br>this->OrthoRenderWidget = vtkKWRenderWidget::New();<br><br>this->ImageViewer2 = vtkImageViewer2::New();<br>this->ImageViewer2->SetRenderWindow( this->OrthoRenderWidget->GetRenderWindow() );
<br>this->ImageViewer2->SetRenderer( this->OrthoRenderWidget->GetRenderer() );<br>this->ImageViewer2->SetInput( this->GetMainXMLImageReader()->GetOutput() );<br>this->ImageViewer2->SetupInteractor( this->OrthoRenderWidget->GetRenderWindow()->GetInteractor() );
<br><br><br>this->scalarRange = this->GetMainXMLImageReader()->GetOutput()->GetScalarRange();<br>this->ImageViewer2->SetColorWindow( this->scalarRange[1] - this->scalarRange[0] );<br>this->ImageViewer2->SetColorLevel(
0.5 * ( this->scalarRange[1] + this->scalarRange[0] ) );<br><br>this->OrthoRenderWidget->ResetCamera();<br>
/* -------- end XML image -------- */<br><br><br><br><div class="gmail_quote">On Nov 9, 2007 4:29 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Jake,<br><br>There shouldn't be any need for a transformation between<br>the image and the polydata that is extracted from it.<br><br>What may be happening is that the code that you are using<br>for displaying the image along with the polydata is not
<br>taking into account the image origin.<br><br>Please look at the image origing of the initial ITK image,<br>and compare it with the image origing of its VTK counterpart.<br><br>Then post to the list the code that you are using for
<br>displaying the vtk image along with the polydata.<br><br>As a simple reference, you can for example display a small<br>sphere centered at the coordinates of the image origin as<br>they are reported in the ITK image.<br>
<br>If you don't see this sphere in the corner of the image,<br>then your display code is not placing the image slices<br>in their right position in space.<br><br>Please let us know what you find.<br><br><br> Thanks
<br><br><br> Luis<br><br><br>-------------------<br><div><div></div><div class="Wj3C7c">Jake Nickel wrote:<br>> I have a program that uses ITK to read in a 3D Analyze format (.hdr,<br>> .img) image, uses the itkImageToVTKImageFilter, and writes two images
<br>> out, one using a vtkXMLImageDataWriter, and the other using a<br>> vtkPolyDataWriter (after the image was passed through a<br>> vtkContourFilter). The code snippet is pasted below.<br>><br>> I then use another program to display these images. The polydata is
<br>> surface rendered and the XML image is rendered as 3 orthogonal images<br>> (transverse, sagittal, and coronal). I have noticed that the polydata<br>> (X, Y, Z) locations returned from picking do not correspond to the same
<br>> X, Y, Z locations in the orthogonal views.<br>><br>> Is there a way that I can retrieve the transformation that has taken<br>> place somewhere between reading in the image and writing it back out as<br>> vtkPolyData so that I have a 2D-3D correspondence?
<br>><br>> Any help is greatly appreciated, Thanks a bunch!<br>> -Jake<br>><br>> ========================<br>> ...<br>> typedef unsigned char PixelType;<br>> const unsigned int Dimension = 3;<br>
><br>> typedef itk::Image< PixelType, Dimension > ImageType;<br>> typedef itk::ImageFileReader< ImageType > ReaderType;<br>> typedef itk::ImageToVTKImageFilter< ImageType > ConnectorFilterType;
<br>><br>> ReaderType::Pointer reader = ReaderType::New();<br>> ConnectorFilterType::Pointer connector = ConnectorFilterType::New();<br>><br>> reader->SetFileName( argv[1] );<br>> reader->Update();
<br>><br>> connector->SetInput( reader->GetOutput() );<br>><br>> vtkXMLImageDataWriter * writer = vtkXMLImageDataWriter::New();<br>> writer->SetInput( connector->GetOutput() );<br>> writer->SetFileName( argv[2] );
<br>> writer->Write();<br>> writer->Delete();<br>><br>> vtkContourFilter * filter = vtkContourFilter::New();<br>> filter->SetInput( connector->GetOutput() );<br>> filter->SetValue( 0, 1 );
<br>><br>> vtkPolyDataWriter * pwriter = vtkPolyDataWriter::New();<br>> pwriter->SetFileName( argv[3] );<br>> pwriter->SetInput( filter->GetOutput() );<br>> pwriter->Write();<br>> pwriter->Delete();
<br>><br>> filter->Delete();<br>> ...<br>> ========================<br>><br>><br></div></div>> ------------------------------------------------------------------------<br>><br>> _______________________________________________
<br>> This is the private VTK discussion list.<br>> Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>> Follow this link to subscribe/unsubscribe:
<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>