[SciPy-User] objects with their Delaunay graphs overlaid.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] objects with their Delaunay graphs overlaid.

franck kalala
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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

objet_and_delaunay_graph_overlaid.png (777K) Download Attachment
cup.png (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: objects with their Delaunay graphs overlaid.

Thiago Franco de Moraes
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 <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: objects with their Delaunay graphs overlaid.

Franck Kalala Mutombo
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: objects with their Delaunay graphs overlaid.

Thiago Franco de Moraes
Try to invert the points:

triangles = tri.Triangulation(points[:,1], points[:,0])

On Wed, Mar 14, 2018 at 2:16 PM Franck Kalala Mutombo <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: objects with their Delaunay graphs overlaid.

franck kalala
It does not bring a big change....

2018-03-14 17:54 GMT+00:00 Thiago Franco Moraes <[hidden email]>:
Try to invert the points:

triangles = tri.Triangulation(points[:,1], points[:,0])

On Wed, Mar 14, 2018 at 2:16 PM Franck Kalala Mutombo <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: objects with their Delaunay graphs overlaid.

Chris Barker - NOAA Federal
first of all, I think scipy's triangulate only does 2D -- those appeared to be 3D images.

But in any case, it only does a convex hull -- if your points are not convex, you need constrained Delaney, which I don't know of a good open-source code for. But triangle is a good one if you can deal with the unclear license:

here is one wrapper:

https://github.com/drufat/triangle

I have no idea if it works.

-CHB






On Wed, Mar 14, 2018 at 6:35 PM, Franck Kalala <[hidden email]> wrote:
It does not bring a big change....

2018-03-14 17:54 GMT+00:00 Thiago Franco Moraes <[hidden email]>:
Try to invert the points:

triangles = tri.Triangulation(points[:,1], points[:,0])

On Wed, Mar 14, 2018 at 2:16 PM Franck Kalala Mutombo <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user




--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user