Re: objects with their Delaunay graphs overlaid.
Thiago Franco Moraes <[email protected]>
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <CAMmoLX-iKHM1S_PJ6ER6VXHmggGB4Bw988WBdDMBi+BmJCUyKg@mail.gmail.com> |
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