4
$\begingroup$

For the following image;

enter image description here

How can I get the vertices (which are highlighted by orange dots) of each Voronoi polygon of the following Voronoi diagram?

The picture is from the Internet. It is just for illustration.

Any suggestions for code to get these vertices?

$\endgroup$
  • 3
    $\begingroup$ I thought it is about image processing of already rendered voronoi diagrams. Could you make clear what exactly is the case? Describe input and desired result? $\endgroup$ – Kuba Jul 18 '18 at 22:32
  • $\begingroup$ Thanks for your comment. It is not about image processing. I just want to get the vertices and the answers were helpful. $\endgroup$ – Eman Jul 27 '18 at 4:24
4
$\begingroup$

Perhaps this example can get you started.

SeedRandom[3]; 
pts = RandomReal[{-1, 1}, {25, 2}];
mesh = VoronoiMesh[pts];
vertices = MeshCoordinates[mesh];
Show[mesh, Graphics[{Black, Point[pts], Red, Point[vertices]}]]

diagram

$\endgroup$
4
$\begingroup$

Try this:

pts = RandomReal[{-1, 1}, {100, 2}];
R = VoronoiMesh[pts];
coords = MeshCoordinates[R];

Here an illustration:

Show[
 R,
 ListPlot[{pts, coords}]
 ]

enter image description here

$\endgroup$
2
$\begingroup$

Just use the "select" tool in the image window, click on the orange points and then paste:

{{243.96083133493207`, 350.65547561950444`}, {264.60431654676256`, 
  342.43405275779384`}, {385.4476418864908`, 
  350.519584332534`}, {394.16866506794565`, 
  343.77697841726626`}, {398.5891286970424`, 
  340.7034372501999`}, {412.4380495603517`, 
  295.72342126298963`}, {493.3133493205436`, 
  159.78417266187043`}, {497.25019984012783`, 
  158.17745803357306`}, {387.1183053557154`, 
  91.79456434852108`}, {421.4068745003997`, 
  164.42046362909664`}, {395.7074340527578`, 
  182.150279776179`}, {326.27498001598724`, 
  158.58513189448433`}, {389.87609912070343`, 
  254.1686650679456`}, {385.7833733013589`, 
  263.4972022382094`}, {359.4524380495603`, 
  258.46522781774576`}, {336.5787370103917`, 
  270.3037569944044`}, {290.4996003197442`, 
  253.44124700239803`}, {280.74740207833736`, 
  162.73381294964022`}, {157.52997601918466`, 
  306.71063149480415`}, {117.18225419664267`, 
  292.05035971223015`}, {216.11111111111111`, 
  223.95683453237405`}, {228.30935251798562`, 
  214.06075139888083`}, {257.33413269384494`, 
  160.35171862509986`}, {219.7322142286171`, 
  114.57234212629888`}, {108.13749000799359`, 147.6738609112709`}}
$\endgroup$
  • $\begingroup$ Thanks for your answer. But the image [that i added], is just an example for illustration. My question is: in general; How can I get the vertices of each voronoi polygon in the voronoi grid by code? If I had center points for each voronoi polygon (which are highlighted in blue ) in the previous image and drew the voronoi grid, then I want to get the vertices points of each voronoi polygon (which are highlighted in orange ), so how can I do that using code? $\endgroup$ – Eman Jul 18 '18 at 20:56
  • 1
    $\begingroup$ See DelaunayMesh. $\endgroup$ – David G. Stork Jul 18 '18 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.