[vtkusers] Apply Texture in PolyData from CT
Wes Turner
wes.turner at kitware.com
Wed Dec 9 11:51:43 EST 2009
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.
- Wes
On Wed, Dec 9, 2009 at 11:37 AM, Paul Jhin <paul.jhin1 at gmail.com> wrote:
> Hi,
>
> 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.
>
> I have the code below but does not display anything. what is wrong can?
>
> What can is wrong, how can I position the texture correctly in volume?
>
> Sorry for English.
>
> Regards,
> Paul Jhin
>
>
> Code:
>
> import vtk
>
> ren1 = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
>
> renWin.AddRenderer(ren1)
>
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> reader = vtk.vtkSTLReader()
> reader.SetFileName("c:\\stl_patient.stl")
>
> outlineMapper = vtk.vtkPolyDataMapper()
> outlineMapper.SetInputConnection(reader.GetOutputPort())
>
> outlineActor = vtk.vtkActor()
> outlineActor.SetMapper(outlineMapper)
>
> img_file = "c:\\patient_photo.bmp"
> img_r = vtk.vtkBMPReader()
> img_r.SetFileName(img_file)
>
> t = vtk.vtkTexture()
> t.SetInputConnection(img_r.GetOutputPort())
> t.InterpolateOn()
>
> outlineActor.SetTexture(t)
>
> ren1.AddActor(outlineActor)
> ren1.SetBackground(1, 1, 1)
> renWin.SetSize(400, 400)
> renWin.Render()
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
Wesley D. Turner, Ph.D.
Kitware, Inc.
Technical Leader
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4920
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091209/aa4bb01f/attachment.htm>
More information about the vtkusers
mailing list