0

Suppose we have an array like this :

A = peaks
A(A<0)=0   % Remove negative values to make things a bit more simple.

I would like to write a script that is able to select the whole volume of the peaks contained in A.

For example, include all the values that surround a local maximum, until it hits values which are either 0 or a local minimum.

Below is a link to an answered question on a similar but more complicated topic.
Find peak (regions) in 2D data

I tried to use the method found on the answer to the question above, but I had little success for my example. I understand that in this answer, on the line:

im3=imextendedmax(im2,10);

, the value 10 acts as some kind of threshold. If I leave the threshold value at 10, it only selects the upper part of the highest of the three peaks (kind of like selecting the snowy top of a mountain, but I would like the whole mountain). I tried to lower it in order to select the entirety of the peaks, but this is the result I get:

enter image description here

enter image description here

In these results, 6 peaks are identified, but what I want is 3 separated peaks, as described in the picture below:

enter image description here

Hope this is clear enough.

  • What do you mean by 'The whole volume of the peaks contained in A'? Do you want to select points, of to calculate some kind of numerical integral? An image would be of great use here – BillBokeey Jun 03 '22 at 12:08
  • When you say 'I tried to use the method found on the answer, but I had little success for my example.'. What did you do? – BillBokeey Jun 03 '22 at 12:17
  • The code in the answer works for your case. Just change the value of the threshold in the call to `im3=imextendedmax(im2,0.2);` for the `peaks` matrix – BillBokeey Jun 03 '22 at 12:31
  • Does this answer your question? [Find peak (regions) in 2D data](https://stackoverflow.com/questions/43852754/find-peak-regions-in-2d-data) – BillBokeey Jun 03 '22 at 12:32
  • Hello @BillBokeey, I just edited the post to explain. Thank you for the suggestion, and for your time. – Aristarchos Jun 03 '22 at 18:33
  • Have you tried with 0.2 by any chance? – BillBokeey Jun 03 '22 at 19:29
  • @BillBokeey Yes, I did try several values including 0.2. In the case of 0.2 specifically, it selects the upper part of each peak, but I would like the whole "mountain", including the "foothills". – Aristarchos Jun 03 '22 at 19:40
  • Changing the `tophat` also affects the output. Using `im2=imtophat(im,strel('disk',100));` starts to incorporate more of the foothills. – magnesium Jun 04 '22 at 07:36
  • Hello @magnesium, i just tried what you suggested and it does improve it indeed. However, it is still not what I want, as I require all the data points. As I mentioned in the post, I need the selection to include everything from the top of the peak to the bottom, until the values are 0, or until it meets another peak (in which case, the local minima would be the border beteen the two peaks). – Aristarchos Jun 04 '22 at 15:43

0 Answers0