Re: objects with their Delaunay graphs overlaid.
Thiago Franco Moraes <[email protected]>
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <CAMmoLX-dktt373AVwEh52nx-TuCb307rpECmdh2SMp3k7nRs2Q@mail.gmail.com> |
Try to invert the points: triangles = tri.Triangulation(points[:,1], points[:,0]) On Wed, Mar 14, 2018 at 2:16 PM Franck Kalala Mutombo <[email protected]> wrote: > Thank you Thiago, > > It is working but the triangulation goes out of the object for some points > and is that I wanted to avoid compare the image I attached. > > Best > > - > Franck Kalala Mutombo, (PhD. Mathematics ) > +243(04)844140 411 | +27(0)7646 91608 > skype: franckm4 > > "*No one knows the future, however, but this does not prevent us to > project** in it and to act as if we control it*" > > > On 14 March 2018 at 16:42, Thiago Franco Moraes <[email protected]> > wrote: > >> You have to use plt.triplot. Also, you can use >> matplotlib.tri.Triangulation to triangulate using the delaunay. Something >> like this: >> >> from matplotlib import pyplot as plt >> >> from skimage.io import imread >> from skimage.feature import corner_harris, corner_subpix, corner_peaks, >> peak_local_max >> import matplotlib.tri as tri >> import matplotlib.pyplot as plt >> >> image = imread("cup.png", as_grey='True') >> points = peak_local_max(corner_harris(image), min_distance=2) >> triangles = tri.Triangulation(points[:,0], points[:,1]) >> fig, ax = plt.subplots() >> ax.imshow(image, interpolation='nearest', cmap=plt.cm.gray) >> ax.triplot(triangles) >> plt.show() >> >> >> >> >> On Wed, Mar 14, 2018 at 1:24 PM Franck Kalala < >> [email protected]> wrote: >> >>> Hello All >>> >>> I am not sure this a good place to ask this. I am just making a try. >>> I have and image and I would like to reproduced the Delaunay graphs >>> overlaid. >>> See the attached image for an idea. >>> >>> I try the following code: >>> >>> from matplotlib import pyplot as plt >>> >>> from skimage.io import imread >>> from skimage.feature import corner_harris, corner_subpix, corner_peaks, >>> peak_local_max >>> from scipy.spatial import Delaunay >>> import matplotlib.pyplot as plt >>> >>> image = imread("cup.png", as_grey='True') >>> >>> >>> #points = corner_peaks(corner_harris(image), min_distance=1) >>> points = peak_local_max(corner_harris(image), min_distance=2) >>> #coords_subpix = corner_subpix(image, coords, window_size=13) >>> tri = Delaunay(points) >>> >>> #imgplot = plt.imshow(image,cmap='gray') >>> #plt.triplot(points[:,0], points[:,1], tri.simplices.copy()) >>> #plt.plot(points[:,0], points[:,1], 'o') >>> #plt.show() >>> #print(image) >>> >>> coords = peak_local_max(corner_harris(image), min_distance=2) >>> coords_subpix = corner_subpix(image, coords, window_size=13) >>> >>> fig, ax = plt.subplots() >>> ax.imshow(image, interpolation='nearest', cmap=plt.cm.gray) >>> ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3) >>> #ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) >>> #ax.axis((0, 350, 350, 0)) >>> plt.show() >>> >>> >>> this code does not help. I attach also the cup image for a try. >>> >>> best >>> >>> franck >>> _______________________________________________ >>> SciPy-User mailing list >>> [email protected] >>> https://mail.python.org/mailman/listinfo/scipy-user >>> >> >> _______________________________________________ >> SciPy-User mailing list >> [email protected] >> https://mail.python.org/mailman/listinfo/scipy-user >> >> > _______________________________________________ > SciPy-User mailing list > [email protected] > https://mail.python.org/mailman/listinfo/scipy-user > _______________________________________________ SciPy-User mailing list [email protected] https://mail.python.org/mailman/listinfo/scipy-user