LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D data peak/valley detection

Hi,

I need to point out all pixels that are peaks and valleys in my 2D array. I thought that I would point them out by building imaginary part of my array and changing corresponding values to 0 and 1 (valley, peak). My question is how to do it quickly and softly. I tried peak detector vi's but they all seem to work with 1D signal only (I cannot change my array to 1D, cause the only condition for peak is that the pixel must have higher value than all 8 closest pixels and 2D - 1D conversion will take it line by line). 

Help 🙂

0 Kudos
Message 1 of 14
(5,757 Views)

Hi,

 

I don't think there is an VI already implemented for that.

 

Can you give more specific information, how big is your array and which are your timming constrains? The first step would be to implement by yourself a very simple alghorithm as taking by the rows from that array and comparing the data to the neighbours (A[i][j] compared to A[i-1][j], A[i+1][j], A[i][j-1] ... and so on)

 

Can you post a text file with your values?

Best regards,

I.R.

0 Kudos
Message 2 of 14
(5,721 Views)

Ok, I didn't describe the problem properly. My 2D array represents 3D surface topography.I need to calculate specific surface parameter. The array is 256x256 and values are generally somwhere between -50 and 50. Now I need to determine how many peaks/pits there are in each interval <-50;-49), <-49; -48), <-48; -47) and so on up to <49; 50). I tried to make double FOR loop so it would check each point separately, and then a while loop inside, but it went out of memory.

 

Vi attached. I replaced my array with one filled with random numbers but it didn't make any difference. What is wrong?

0 Kudos
Message 3 of 14
(5,684 Views)

Hi Ofic,

 

do you need a simple histogram? Why not use the histogram functions?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 14
(5,680 Views)

Histogram won't tell me about peaks and pits, only about amplitude distribution. I need something like... a histogram, that takes only peaks, and another that takes only pits. Maybe remove other points from the array somehow?

0 Kudos
Message 5 of 14
(5,674 Views)

Hi Ofic,

 


Now I need to determine how many peaks/pits there are in each interval <-50;-49), <-49; -48), <-48; -47) and so on up to <49; 50).


 

Sounds like you need a histogram over your data with an interval width of 1. Easily to get with the histogram function as shown above...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(5,671 Views)

Ok I get it. I will use histograms later.

First I need to get rid of all non-peak and non-pit points by replacing them with zeros. My vi. doesn't work and I'm not sure if I know why. I want to receive an array with zeros and (if the point is a peak) values of the points.

Vi. attached.

 

I thought that the problem is maybe that the program doesn't know next rows until it gets there, but I don't know how to avoid it.

0 Kudos
Message 7 of 14
(5,649 Views)

Hi,

 

maybe this VI will help you.

Basically it searches in the 2D arrays for peaks, and returns back an array of cluster, each cluster contains two integer value (row and column number) where there was a peak detected.

 

Best regards,

I.R.

Download All
0 Kudos
Message 8 of 14
(5,643 Views)

I need the value of the peak too.

0 Kudos
Message 9 of 14
(5,634 Views)

well, you can parse one more time and extract the values, now that you know the coordinates, it is easy to read the peak values.

 

Best Regards,

I.R.

0 Kudos
Message 10 of 14
(5,620 Views)