LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find all max values and thier indices in a 2-D array

I need help finding the first value in a 2D array that is not directly next to the higher values.  I am attaching a VI that illustrates what I am doing.  The problem is that it takes too long.  Does anyone know how to make it quicker?  It would be nice if their was a VI that returned all indeces the of the max value in an array instead of just the first one?  Thanks for any suggestions.
 
Kevin Baker
0 Kudos
Message 1 of 18
(7,241 Views)
Hi:

I could not find the link to the vi. However, if I got you correctly,
here is how you'll do it (based on the assumption that the array
contain numbers):

1. Find the max value
2. Then use threshold detector to find the index

Let me know.

Nasir
kbaker wrote:
> I need help finding the first value in a 2D array that is not directly next to the higher values.  I am attaching a VI that illustrates what I am doing.  The problem is that it takes too long.  Does anyone know how to make it quicker?  It would be nice if their was a VI that returned all indeces the of the max value in an array instead of just the first one?  Thanks for any suggestions.
>  
> Kevin Baker
>
>
> Find all max.vi:
> http://forums.ni.com/attachments/ni/170/223993/1/Find all max.vi

0 Kudos
Message 2 of 18
(7,230 Views)
Hi:

I could not find the link to the vi. However, if I got you correctly,
here is how you'll do it (based on the assumption that the array
contain numbers):

1. Find the max value
2. Then use threshold detector in a while loop and to find the index

Let me know.

Nasir
kbaker wrote:
> I need help finding the first value in a 2D array that is not directly next to the higher values.  I am attaching a VI that illustrates what I am doing.  The problem is that it takes too long.  Does anyone know how to make it quicker?  It would be nice if their was a VI that returned all indeces the of the max value in an array instead of just the first one?  Thanks for any suggestions.
>  
> Kevin Baker
>
>
> Find all max.vi:
> http://forums.ni.com/attachments/ni/170/223993/1/Find all max.vi

0 Kudos
Message 3 of 18
(7,230 Views)
Hi Kevin
 
You can do Array Min & Max to do the job quicker. You use this function to find the max value in your 2D array. Once you know the max value you can then use this to calculate how many max values occur in you data. The number of max values is then used for the number of iterations in a for-loop. In each iteration of the for loop, you use Array Min & Max to return the index of the maximum value index row and col. Once you have an row and column you need to reset the max value found at that location so that the next loop iteration finds the next row and col index.
 
Example attached in LV8
 
David
0 Kudos
Message 4 of 18
(7,213 Views)

Sorry Kevin.

I have just looked over you post and vi and I am not on the right track. I think you are looking for several peaks in the data.

Mmm, I shall meditate on this, I will.

David

0 Kudos
Message 5 of 18
(7,209 Views)
Thanks.  I am trying to find the first peak (and its corresponding location) that is not directly next to the other other higher peaks in the 2D array.  Thanks again.
 
Kevin Baker 
0 Kudos
Message 6 of 18
(7,194 Views)
I am still trying to get my head around what you want.
 
Does the VI you posted give the answers you want but just want to make this faster?
 
However, your previous reply implies that there is one answer. Based on you data set what should be the answer (Peak Value, Row Index, Column Index) and could you demonstrate why?
 
Trying to help ...
 
David
0 Kudos
Message 7 of 18
(7,184 Views)

Thanks David.  That is right the VI does give the right answer, but it just takes too long for my application.  Yes I am just looking for one answer, but I output more than I need in the VI for inspection.  The While loop stops when a peak is found that is not directly next to the higher peaks.  When I say "not directly next to the higher peaks" I mean that the peak value I am looking for is more than +-1 index value away along both directions from the other peaks in the 2D array.   Sorry for the confusion, it is difficult to describe.  I only require the value of this peak.  It just seems that I should be able to use a Labview VI, or clean up the VI that I attached to make it go faster.  Maybe not..., then I will have to just deal with this VI.  Thanks again.

Kevin Baker

0 Kudos
Message 8 of 18
(7,179 Views)
Hi Kevin
 
Try this code. It looks at the maximum value in the array and checks that is higher that all surrounding elements which means it is a peak. If the max is not a peak it moves to the next max value.
 
Let me know if this is what you want.
 
David
0 Kudos
Message 9 of 18
(7,171 Views)

Well, I still don't get the problem. It would clarify what you mean by "peak".  Your original data shows a single spherical feature (see attached picture of your data shown in a zoomed intensity graph). So... what do you want to find?

  1. the white highlight of the sphere?
  2. The center position of the sphere?
  3. Do you want to detect how many such spheres are in your array and find their position?
  4. ??

David, since the array is I16, you should replace with -32768 else the program will start failing if the data has a large negative offset (e.g. if the background plane is at -1000 an the peak or array max is -10).

Message Edited by altenbach on 01-14-2007 11:04 AM

0 Kudos
Message 10 of 18
(7,164 Views)