I have to find the local minima and maxima corresponding to the "peaks" and "valleys" of a data file.

조회 수: 1 (최근 30일)
Given this data file (which contains two vectors for x and y coordinates along with a 2D matrix corresponding to altitude), I have to find the specific local maxima and minima (coordinates and altitude) that correspond to the "peaks" and "valleys" of the data (excluding hills on the borders of the plot). After plotting the altitude matrix using surf, it's easy to see that there are three obvious peaks and three obvious valleys, but I'm not sure how to find specific coordinates or altitude. How should I do this? I'm sure the way to do it is by writing a specific loop that allows you to examine the points to find the largest ones, but I've been messing around with it for a while and haven't gotten anywhere. For reference, I've been told that I can't use add-ons or toolboxes that would simplify this procedure, so that's made it a lot more annoying.

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 14일
Have you worked with fminsearch() fcn of optimization toolbox:
https://www.mathworks.com/help/matlab/ref/fminsearch.html
  댓글 수: 1
John Henderson
John Henderson 2021년 11월 14일
I have not used it before, no. Would that provide me with all of the necessary minimums or just the global minimum?

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2021년 11월 15일
편집: Image Analyst 2021년 11월 15일
You can try imregionalmin() and imregionalmax() to find where the local max and min lie.
Also see Steve's blog on finding peaks in 2-D images:
  댓글 수: 2
John Henderson
John Henderson 2021년 11월 17일
Don't both those functions require the image processing toolbox? I've definitely explored that route, but I'm more interested in doing this without the use of additional toolboxes that I have to install.
Image Analyst
Image Analyst 2021년 11월 17일
Yes. However you can simply do a brute force search. Search every location in the array and see if it's greater than or equal to any other elements in the local window. Shouldn't take too long for a few million pixels.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by