[vtkusers] get texture at any point on a cell

Tim Hutton T.Hutton at eastman.ucl.ac.uk
Fri Oct 10 13:27:26 EDT 2003


Hi Theodoros,

I do exactly this. The easiest way I've found in VTK is to do the following:

1) Create a new vtkPolyData ('tcoord_triangles' below) containing the same 
cells as the surface but with each point set to the tcoord of the vertex. 
This gives you a flattened-out version of the surface, lying on the texture 
map.

2) Use vtkCellLocator and a global-dataset-global coord transform to find 
the tcoords corresponding to any 3D point:

surface_locator->FindClosestPoint(input_point,pt1,cell,id,subid,dist2);
cell->EvaluatePosition(pt1,pt2,subid,pcoords,dist2,weights); // (pt2 should 
emerge == pt1)
tcoord_triangles->GetCell(id)->EvaluateLocation(subid,pcoords,pt3,weights);

3) Then you can sample the image at the correct place:

int tx = pt3[0]*input_dim[0]; // convert the [0,1] range of tcoords into pixels
int ty = pt3[1]*input_dim[1];
... input_image->GetPointData()->GetScalars()->GetTuple(tx+ty*input_dim[0])

It's a little fiddly but should do the trick. If you can think of a way of 
making this into a filter it might be useful to other VTK users. Not that 
many people work with texture images like this though, it seems to me.

Also, if anyone knows of an easier way to do this then let me know!

Thanks,

Tim

At 18:07 10/10/2003 +0100, Theodore Papatheodorou wrote:
>Hi,
>I have a 3D surface and a BMP file used as texture. I know the texture
>coordinates of each vertex on the surface and I therefore can retrieve
>intensity information. I would like to be able to retrieve intensity
>information for any point even if it is in the middle of a cell. Does
>anyone know how to do this? There should be a function that does that.
>Any ideas?
>
>Theodoros Papatheodorou
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers

---------------------------------------------------------------------------
Tim Hutton,                           http://www.eastman.ucl.ac.uk/~thutton
Research Fellow & PhD student,                   T.Hutton at eastman.ucl.ac.uk
MINORI Project, Biomedical Informatics Unit,
Eastman Dental Institute, UCL,                   Tel: [+44] (0)20 7915 2344
256 Gray's Inn Road, London WC1X 8LD, UK         Fax: on request
---------------------------------------------------------------------------
This email represents the views of the sender alone and must not be 
construed as representing the views of the Eastman Dental Institute. It may 
contain confidential information and may be protected by law as a legally 
privileged document and copyright work. Its content should not be disclosed 
and it should not be given or copied to anyone other than the person(s) 
named or referenced above. If you have received this email in error, please 
contact the sender.





More information about the vtkusers mailing list