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).
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?
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?
do you need a simple histogram? Why not use the histogram functions?
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?
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...
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.
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.
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.
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.