In order to display texture on a polydata you need to generate a texture coordinates array on the polydata. That can be a difficult prospect, but take a look at vtkProjectedTexture ... by setting up vtkProjectedTexture to mimic your actual physical camera position and settings at the time you took the photo, you can get appropriate texture coordinates on the polydata. Again, this is not always trivial and you may have to play with it to get it correct.<div>
<br></div><div>- Wes<br><br><div class="gmail_quote">On Wed, Dec 9, 2009 at 11:37 AM, Paul Jhin <span dir="ltr"><<a href="mailto:paul.jhin1@gmail.com">paul.jhin1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I have an STL file of a face, generated by CT, I have a picture of the patient, I would like to use this picture as a texture. <br><br>I have the code below but does not display anything. what is wrong can?<br>
<br>
What can is wrong, how can I position the texture correctly in volume?<br><br>Sorry for English.<br><br>Regards,<br>Paul Jhin<br><br><br>Code:<br><br>import vtk<br><br>ren1 = vtk.vtkRenderer()<br>renWin = vtk.vtkRenderWindow()<br>
<br>renWin.AddRenderer(ren1)<br><br>iren = vtk.vtkRenderWindowInteractor()<br>iren.SetRenderWindow(renWin)<br><br>reader = vtk.vtkSTLReader()<br>reader.SetFileName("c:\\stl_patient.stl")<br><br>outlineMapper = vtk.vtkPolyDataMapper()<br>
outlineMapper.SetInputConnection(reader.GetOutputPort())<br><br>outlineActor = vtk.vtkActor()<br>outlineActor.SetMapper(outlineMapper)<br><br>img_file = "c:\\patient_photo.bmp"<br>img_r = vtk.vtkBMPReader()<br>
img_r.SetFileName(img_file)<br>
<br>t = vtk.vtkTexture()<br>t.SetInputConnection(img_r.GetOutputPort())<br>t.InterpolateOn()<br><br>outlineActor.SetTexture(t)<br><br>ren1.AddActor(outlineActor)<br>ren1.SetBackground(1, 1, 1)<br>renWin.SetSize(400, 400)<br>
renWin.Render()<br><br>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<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>
<br></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>
</div>