python - Create a triangular mesh using Delaunay methods -


i'm trying create triangular mesh using python. know boundary points, think delaunay method more appropriated. tried use scipy. code simple

from scipy.spatial import delaunay pixelpoints = np.transpose(np.nonzero(binaryimage)) tri = delaunay(pixelpoints) import matplotlib.pyplot plt plt.triplot(pixelpoints[:,0], pixelpoints[:,1], tri.simplices.copy()) plt.plot(pixelpoints[:,0], pixelpoints[:,1], 'o') plt.show() 

output triangulation don't want this. i'd mesh inside image bounds. also, don't want mesh inside holes. can control number of triangles cover surface? there alternative way this?

thank you.

you can remove additional triangles using polygon.ispointinside(tcentroid) tcentroid triangle centroid. ispointinside() can derived this: http://geomalgorithms.com/a03-_inclusion.html.


Comments