From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert 2D array to 1D array of cluster of 2 elements

Solved!
Go to solution

Hi,

 

I'd like to convert a 2D array to 1D array of cluster of 2 elements and I don't know how to do it.

I use IMAQ ImageToArray to have a 2D array like that :

0 0 0 255 255 0 0 0

0 255 0 0 0 0 255 0

255 0 0 0 0 0 0 255

0 255 0 0 0 0 255 0

0 0 0 255 255 0 0 0

and now I'd like to use IMAQ Fit Circle 2 but it needs "1D array of cluster of 2 elements" in input. More specifically, it needs an array of point coordinate cluster (with minimum 3 points coordinate cluster).

 

See my diagram attached.

Thanks a lot

0 Kudos
Message 1 of 18
(6,846 Views)

Which elements in the 2D array go to what locations in the cluster and in the 1D array?

 

For a 2D array like this (with multiple values so we can tell which element moves where):

 

0     1    2    3     4

5     6    7    8     9

10  11  12  13  14

15  16  17  18  19

 

does the 1D array become [0,1]  [2,3] [4,???] ...    Is the next element [4,5] or is the odd numbered element dropped and the next point becomes [5,6]?

or does it become [0,5] [1,6]  [2,7] [3,8]  [4,9]  then [5,10] or [10,15] ?

or some other pattern?

 

Lynn

0 Kudos
Message 2 of 18
(6,815 Views)

I don't know how to answer to your question because I don't really know what I have to do.

I have something like this :

 

0 0 0 255 255 0 0 0

0 255 0 0 0 0 255 0

255 0 0 0 0 0 0 255

0 255 0 0 0 0 255 0

0 0 0 255 255 0 0 0

 

and I just want to find the best circle (using IMAQ Fit Circle 2)

this VI needs in input an "1D array of cluster of 2 elements" more precisely "an array of point coordinate cluster", I understand that he wants coordinates of all my points wich have a value of 255.

So, for the first point 255, I think I need to have [1,4] (First line, Fourth colomn)

Maybe I'm wrong, I don't know if you understand the problem like me

 

 

0 Kudos
Message 3 of 18
(6,790 Views)

@Noovn wrote:

this VI needs in input an "1D array of cluster of 2 elements" more precisely "an array of point coordinate cluster", I understand that he wants coordinates of all my points wich have a value of 255. 

So, for the first point 255, I think I need to have [1,4] (First line, Fourth colomn)


 


Well exactly! So what is problem? With getting coordinates of those points? 

Here's an example how to do it:

0 Kudos
Message 4 of 18
(6,776 Views)

If I ask the question here it's because I didn't find an answer in Labview help...

Indeed, I need to find coordinates of my points equal to 255.

I tried to use Min/Max of an array to have index of my maximums (255), but it gives me only the first point equal to 255, or I need all indexes of all my maximum.

How can I do that ?

0 Kudos
Message 5 of 18
(6,772 Views)

Thanks Adam Trojak !! I will try this !

0 Kudos
Message 6 of 18
(6,767 Views)

If you;re referring to the Radial Points input of Imaq fit circle 2

 

then yes, you need coordinates of all your '255' values.

 

To get these from your 2D array, consider something simple, such as:

radialpoints.png

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 7 of 18
(6,764 Views)

thanks all for your response.

 

Thoric, in you diagram what do you use ?

 

(I circle in red some things that I don't understand)

Is it "build array" ? because my icon is not exactly the same but maybe it depends on your version of Labview

 

solution.png

0 Kudos
Message 8 of 18
(6,748 Views)

The first circle is an Array Constant with a cluster of two I32s in it.  I is basically a constant of what your output should be, except the array is empty.

 

The second one is the Build Array.  The icon changes based on what is wired into it.  In this case, we are adding a scaler to an array.  Once you wire it up, it should match just fine.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 18
(6,744 Views)

Now it's ok but I don't understand why Labview give me an error : "You supplied an insufficient number of points to perform this operation."

However, on my image (white circle) there are lot of points wich are at 255.

 

So what is the problem ?

 

 

solution.png

0 Kudos
Message 10 of 18
(6,733 Views)