<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi all,<br><br>I have a vtk mesh that I would like to register with a nifti image.<br>I tried to convert it to an image using this page, by changing the c++ code to python : http://www.paraview.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData<br>It gave me a MetaImage (a .mhd file and .raw file) that doesn't help me for the registration...<br><br>How could I get a nifti image from this mesh ? (nifti or any other image format that I could register with a nifti)<br><br>Here is the Python vtk code to create the mesh (generates a long cylinder named 'stem' and a smaller one named 'c1') :<br><br> import vtk<br><br> # create a rendering window and renderer<br> ren = vtk.vtkRenderer()<br> renWin = vtk.vtkRenderWindow()<br> renWin.AddRenderer(ren)<br> <br> # create a renderwindowinteractor<br> iren = vtk.vtkRenderWindowInteractor()<br> iren.SetRenderWindow(renWin)<br><br><br> # create stem<br> stem = vtk.vtkCylinderSource()<br> stem.SetCenter(0,0.73875,0)<br> stem.SetRadius(0.0063)<br> stem.SetHeight(1.5225) # 2.25 + 150<br> stem.SetResolution(100) # number of facets to define cylinder<br><br> # create c1<br> c1 = vtk.vtkCylinderSource()<br> c1.SetCenter(0,0,0)<br> c1.SetRadius(0.00635)<br> c1.SetHeight(0.03)<br> c1.SetResolution(100)<br><br> # mappers<br> stemMapper = vtk.vtkPolyDataMapper()<br> stemMapper.SetInput(stem.GetOutput())<br><br> c1mapper = vtk.vtkPolyDataMapper()<br> c1mapper.SetInput(c1.GetOutput())<br><br> # actors<br> stemActor = vtk.vtkActor()<br> stemActor.SetMapper(stemMapper)<br><br> c1Actor = vtk.vtkActor()<br> c1Actor.SetMapper(c1mapper)<br> c1Actor.GetProperty().SetColor(1.0,0,0)<br><br> # assign actors to the renderer<br> ren.AddActor(stemActor)<br> ren.AddActor(c1Actor)<br><br> # display axes<br> axes = vtk.vtkAxesActor()<br> ren.AddActor(axes)<br><br> # enable user interface interactor<br> iren.Initialize()<br> renWin.Render()<br> iren.Start()<br><br><br>Thank you for your help. Regards,<br><br>Jude<br>                                            </div></body>
</html>