Steve on Image Processing

May 31st, 2007

Upslope area - Plateau detection

In my previous upslope area post, I showed this graphic of pixel flow around North Pond in Milford, Massachusetts:

Notice that pixels in the pond have no arrows. In fact, the pixelFlow M-file I showed previously is unable to compute a pixel flow direction or magnitude for these pixels because they are in a flat region, or plateau. More specifically, pixelFlow returns a flow direction of NaN for any pixel that has no downhill neighbor.

There is a simple way to find all such pixels using morphological erosion. Erosion with a flat structuring element is equivalent to a local minimum operator. If the minimum value of a pixel and its neighbors equals the pixel itself, then we'll call it a plateau pixel.

s = load('upslope_sample_dem');
pond = s.Zm(140:280, 160:230);
plateaus = imerode(pond, ones(3,3)) == pond;
imshow(plateaus, 'InitialMagnification', 'fit')
title('Plateaus')

I'd like to classify plateaus into three types:

  • plateaus with downhill but no uphill neighbors; these are called regional maxima
  • plateaus with uphill but no downhill neighbors; these are called regional minima
  • plateaus with both uphill and downhill neighbors

The Image Processing Toolbox has functions that find regional maxima and regional minima:

max_plateaus = imregionalmax(pond);
imshow(max_plateaus, 'InitialMagnification', 'fit')
title('Max plateaus')
min_plateaus = imregionalmin(pond);
imshow(min_plateaus, 'InitialMagnification', 'fit')
title('Min plateaus')

We can now identify pixels in plateaus with both uphill and downhill neighbors by using logical operators:

mid_plateaus = plateaus & ~(max_plateaus | min_plateaus);
imshow(mid_plateaus, 'InitialMagnification', 'fit')
title('Mid plateaus')

Next time I'll work on a procedure for calculating flow directions for these different kinds of plateau pixels.


Get the MATLAB code

Published with MATLAB® 7.4

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Steve Eddins manages the Image & Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.

  • Sana: hi steve, could you explain to me how i would be able to use the dir function, to do a loop through a directory...
  • Nishtha: Sir, I have preprocessed the image in following steps: [1] adaptive histogram equalization [2] thresholding...
  • Kristof: I also strongly support the idea. I have just recently bumped into the problem that im2single was not...
  • Steve: David—I’ m glad you found it useful!
  • David Lalejini: I found your example very useful for finding connected nodes in a large set of input pairs. I start...
  • tommy: Dear Steve, I have a question,please if you are kind to help me regarding the accumulator array dimensions of...
  • Steve: Abc—I don’t know how to distinguish the faces. You might try posting your question in the MATLAB...
  • Manju: well if we have a few ovals within each other like in a cell how do we measure the distance from the center...
  • Steve: Manju—What do you mean? How is each region defined?
  • Manju: if we have 2-3 regions within each other how do we measure the regions of each one?

These postings are the author's and don't necessarily represent the opinions of The MathWorks.