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.

  • Steve: Kezia—Try imrotate.
  • kezia: steve, how to perform rotation of structuring element by 15 degrees. kindly answer my question. thank u kezia...
  • Steve: Tasha—I only accept comments that are relevant to the particular blog post or are questions or comments...
  • Tasha: Steve,I send you a comment here but still didn’t get any reply yet.I did not see my comment posted here...
  • Steve: Carsten—Thanks for your input.
  • Carsten: Another vote for either imtranslate.m, or at least a blurb in the imtransform help why pure translation...
  • Loren Shure: If you look towards the end of the fftfilt program, you will see that there’s a check to see if...
  • Steve: Sonja—My imwritesize submission on the MATLAB Central File Exchange might be helpful. It was posted...
  • Steve: Grant—Sorry, but it won’t be for R2010a. That development deadline has already passed.
  • Sonja: My publisher is wanting images for a new book to be 300 dpi. Only 5 of the 19 images are 300, the rest are...

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