I am looking for a solution to find local maxima in 2D arrays. Something like the PeakDetector.vi does but for 2D data.
For absolute extrema, you can use Array Min & Max. It is polymorphic to accept multiple dimension arrays and will give you the value and location of the extremum.
Local extrema are a bit harder. I don't know of any out of the box tool to do that for you, but basically all you need to do mathematically is find the gradient and the location where it is equal to 0 (or close enough to 0). The gradient is just [dz/dx, dz/dy].
You can use transpose array and then apply the derivative VI for each row. Then look for where both are 0 (or within a deadband). To determine whether they are maxima or minima, take the second derivative in one direction (there is no real need to do it in both directions, because if it is truly a local extremum, then both second derivatives will have the same sign.
I coded this up, quick and dirty. Hopefully it is a starting place for you.
I put some sample data to a constant in the VI attached.
Well, so which local peaks do you want? I can see about three, see image.
As I asked before, are all data sets similar (e.g. similar width of the peaks, similar locations, similar shape and symmetry, etc.) or is each dataset very different?
The data looks like some low order spherical harmonics projected on a plane. Is this theoretical noiseless data or a real measurement (I cannot easily tell if there is noise).
If it is simulated data, what is the math behind it? maybe you can fit to the actual model function and get the entire shape.
There is no function to describe the data.
In the mean time I just took the easy approch and looked for the maximum values with certain minimum distances to each other.
I think this will do the job for the moment.
I remember a similar post a long (relatively) time ago. Attached is a way to get the local maxima. It is a crude version that badly need to be improve for efficiency (it takes 20-25 sec to get the local maxima of your 2D array!) but it probably be used as a starting point.