I have a 2D array/matrix (something like an image, but it's not an actual image) with values from 0 to X (in this case 180). and I have a 1D array/Vector that has the occurrence frequency of these values in the 2D matrix (I think it's like Histogram, but I've done that manually).

so the 1D array can look like this. 1D array representing the occurrence of the 2D array

I want to segment it based on peak values. I mean I want to get each mountain separately. so let's say every cell (or pixel in the 2D array) that has a value between 0 and 30 will have the label 1, and the values between 30 and 150 will have the label 2, and the values from 150 to 180 will have the label 3. (that's in case of 3 labels only -which is fine-). but I could want to do it with more than that for example from 0 to 5, then from 5 to 18 etc. so segment each peak separately. I used the findpeak matlab function, but I've only got peaks (which represent the center of my range). I thought of getting every 2 consecutive peaks and then segment based on half the distance between them, but that will give a bad result between 20 and 150 for example. looking for local minima might be useful but I think there's no function in matlab for that. and if I want to go in this approach I'm afraid of getting too many results in the long valley range (which I don't need). I don't know if there's a better idea. so to reformulate the question, eventually I want to segment a 2D array based on the most occurred values.

Any ideas or scientific keywords can be helpful, because I'm a newbie in this area.

(and here's another example)

another example with 3 main mountains

and the function I'm using to show the peaks for now:

[pks,locs] = findpeaks(data, 'MINPEAKHEIGHT', 200);

  • $\begingroup$ I am unsure what the problem is. You want to find the peaks of the histogram, correct? But you only want the peaks above a certain level? If so, can't you just threshold your current results? $\endgroup$ – AnonSubmitter85 Jan 24 '14 at 21:09
  • $\begingroup$ what do you mean by thresholding? I think that will not separate the first peak group, than the second peak group (if I understand thresholding as getting the values with freq > 200) $\endgroup$ – Reem Jan 24 '14 at 21:28
  • $\begingroup$ What are your criteria for segmentation? $\endgroup$ – AnonSubmitter85 Jan 24 '14 at 22:11
  • $\begingroup$ I want the most occurred values to be separated (or segmented or grouped together) $\endgroup$ – Reem Jan 24 '14 at 22:14
  • $\begingroup$ But that is exactly what finding the peaks of the histogram will do. I'm sorry, but I can't follow. Good luck. $\endgroup$ – AnonSubmitter85 Jan 24 '14 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.