Question about finding pits of a matrix?

o

2 Comments

Johny - don't do that. Don't edit away your question. It really annoys people a lot.

Sign in to comment.

 Accepted Answer

Matt J
Matt J on 16 Nov 2013
Edited: Matt J on 16 Nov 2013
If I've understood what you're after, the whole task is doable in just a few lines,
minval=min(map(:)); %minimum cell value
pitmap=(map==minval); %all minima/pits
pitmap([1,end],[1,end])=false; %get rid of edge pits
[pitrows,pitcols]=find(pitmap); %pit coordinates

3 Comments

So you're saying "pits" are local minima, not global ones? If so, you can use imregionalmin and some small modifications to my code above
pitmap=imregionalmin(map);
pitmap([1,end],[1,end])=false; %get rid of edge pits
[pitrows,pitcols]=find(pitmap); %pit coordinates
output=[pitrows,pitcols];
I agree with Matt about using imregionalmin(). By the way, you might find this interesting: http://www.mathworks.com/matlabcentral/fileexchange/35452-finddepressions
This looks promising It seems this mregionalmin function uses 8-connected neighborhoods for 2D images, but I have to take into account the points on the input matrix which are themselves the minimum, aka offset of (0,0) which means that it should scan for the local minimum within the cell itself as well. does Imregionalmin do this?

Sign in to comment.

More Answers (0)

Asked:

on 16 Nov 2013

Commented:

on 5 Apr 2023

Community Treasure Hunt

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

Start Hunting!