Find all the points inside a triangulation

9 visualizaciones (últimos 30 días)
Karthik Uthaman
Karthik Uthaman el 17 de Oct. de 2011
I am currently working on problem in which I am using delanauy triangles to warp and morph two images.
Say i have
%These are the points marked on two different images that are to be morphed....
im2_pts = [y2(:) x2(:)];
im1_pts = [y1(:) x1(:)];
%calculating the average shape...
avg_pts=[x_avg(:) y_avg(:)];
%Triangulation...
tri = delaunay(x_avg,y_avg);
%For each triangle in tri i will perform the action below...
%First Triangle's co-ordinates
t1_x = [ 2736 1882 2736];
t1_y = [ 2736 1060 1];
%Second Triangle's co-ordinates
t2_x = [ 2736 1933 2736 ];
t2_y = [ 2736 991 2736 ];
tri1 = [t1_x(:) t1_y(:)];
tri2 = [t2_x(:) t2_y(:)];
%calculating the affine transformation...
t_affine = cp2tform(tri1,tri2,'affine');
now to apply the transformation, i need to find out all points in the triangle tri1. I know i need to use tsearch for the same. But i am not sure how to use it.
Please do let me know how do i perform this action. Thanks !!!! :D

Respuestas (1)

Florin Neacsu
Florin Neacsu el 17 de Oct. de 2011
Hi,
Given any triangle, defined by the coordinates of its vertices you can "easily" find the interior points. Have a look at barycentric coordinates. Define a barycentric coordinate system with the triangle's vertices. Then any point will have 3 coordinates say a,b,c. If they all are positive then the point is inside the triangle. If not, the point is outside.
Hope this helps. Regards, Florin
  1 comentario
Karthik Uthaman
Karthik Uthaman el 17 de Oct. de 2011
can you give me a sample code?
do u have any idea how to use tsearch?

Iniciar sesión para comentar.

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by