LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating Voronoi Images/ Tessilation for a set of 2D points

I'm slowly getting to grips with labview, mathscripts and so on.

 

My problem is i have a 2D array of real numbers, which correspond to points spread out in X and Y (see image)

 

I would like to calculate the associated Voronoi Tessilation that corresponds to these points. Now it says this can be done in a mathscript window, along the lines of :

 

(http://zone.ni.com/reference/en-XX/help/371361D-01/lvtextmath/msfunc_voronoi/)

Syntax

voronoi(a, b)

[x, y] = voronoi(a, b)

Description

Generates the Voronoi diagram of specified points in a plane. If you do not request an output, this function plots the Voronoi diagram in conjunction with the original points in the current plot window.

Examples

Inputs

Name Description
a Specifies a vector of x-coordinates of points in the plane.
b Specifies a vector of y-coordinates of points in the plane. length(b) must equal length(a).

Outputs

Name Description
x Returns a 2-by-n matrix of real numbers. n is the number of x-coordinates of Voronoi points. LabVIEW defines the edges of the Voronoi diagram by all lines from (x(k), y(k)) to (x(k + 1), y(k + 1)).
y Returns a 2-by-n matrix of real numbers. n is the number of y-coordinates of Voronoi points.

Examples

A = rand(12, 1);
B = rand(12, 1);
voronoi(A, B);

 

 

-----

 

I thought i had wired up the mathscripts window correctly, to at least generate the 2-by-n matrix it should generate but no luck.

 

Can anyone help, please. It maybe (an most likely) that i'm doing something stupid in the mathscript window, and not putting it in the correct syntax. 

 

 

The same also goes for dong Delauney triangulation which i can't also get to work properly.

 

----

 

Any help would be most welcome and certainly greatly received.

 

Thanks.

Jon.

 

0 Kudos
Message 1 of 3
(3,429 Views)
Hello Jon,

Where are you having difficulty?  Your text says the MathScript Window, but your image shows the MathScript node.  If you are working in the MathScript Window, can you post the text you used?  If you are working in the node, you have everything set up properly.  Your two output matrices should be 2-by-n matrices of points.  These points form line segments of the voronoi diagram.  As long as your "x- Array" and "y- Array" inputs are the same length, you should have no problem.  Try creating an error out indicator from the MathScript node.  It will show you if any error is being generated.

If you still have difficulty, please post a VI with what you are currently using and describe what is happening / what you expect.  It will help us to identify what is going on.

Grant M.
Staff Software Engineer | LabVIEW MathScript | National Instruments
0 Kudos
Message 2 of 3
(3,413 Views)

Thanks for this.

 

As you said, it all looked ok. I was using a mathscript node, and not a mathscript window and i wondered if i'd written something stupid in the mathscript node.

 

I repeated what i had done, admittedly in v8.6, and everything seems to be working spot on. (see attached VI as example of generating Voronoi diagram from an array of random number).

 

I've overlayed it onto a blank image, but doing similar onto an image of  points isn't too hard.

 

Thanks for the help in any case.

 

hopefully this Vi might be of use to someone else.

 

Chhers,

jon.

0 Kudos
Message 3 of 3
(3,386 Views)