Image Processing Toolbox    

Finding Peaks and Valleys

Grayscale images can be thought of in three-dimensions: the x- and y-axes represent pixel positions and the z-axes represents the intensity of each pixel. In this interpretation, the intensity values represent elevations as in a topographical map. The areas of high-intensity and low-intensity in an image, peaks and valleys in topographical terms, can be important morphological features because they often mark relevant image objects.

For example, in an image of several spherical objects, points of high intensity could represent the tops of the objects. Using morphological processing, these maxima can be used to identify objects in an image.

This section covers these topics:

Understanding the Maxima and Minima Functions

An image can have multiple regional maxima or minima but only a single global maxima or minima. Determining image peaks or valleys can be used to create marker images that are used in morphological reconstruction. For a detailed example, see Example: Marker-Controlled Watershed Segmentation.

This figure illustrates the concept in 1-D.

Finding Areas of High- or Low-Intensity

The toolbox includes functions that you can use to find areas of high- or low-intensity in an image:

The functions accept a grayscale image as input and return a binary image as output. In the output binary image, the regional minima or maxima are set to 1; all other pixels are set to 0.

For example, this simple image contains two primary regional maxima, the blocks of pixels containing the value 13 and 18, and several smaller maxima, set to 11.

The binary image returned by imregionalmax pinpoints all these regional maxima.

You may want to only identify areas of the image where the change in intensity is extreme; that is, the difference between the pixel and neighboring pixels is greater than (or less than) a certain threshold. For example, to find only those regional maxima in the sample image, A, that are at least two units higher than their neighbors, use imextendedmax.

Suppressing Minima and Maxima

In an image, every small fluctuation in intensity represents a regional minima or maxima. You may only be interested in significant minima or maxima and not in these smaller minima and maxima caused by background texture.

To remove the less significant minima and maxima but retain the significant minima and maxima, use the imhmax or imhmin functions. With these functions, you can specify a contrast criteria or threshold level, h, that suppresses all maxima whose height is less than h or whose minima are greater than h.

For example, this simple image contains two primary regional maxima, the blocks of pixels containing the value 14 and 18, and several smaller maxima, set to 11.

To eliminate all regional maxima except the two significant maxima, use imhmax, specifying a threshold value of 2. Note that imhmax only affects the maxima; none of the other pixel values are changed. The two significant maxima remain, although their heights are reduced.

This figure takes the second row from the sample image to illustrate in 1-D how imhmax changes the profile of the image.

Imposing a Minima

You can emphasize specific minima (dark objects) in an image using the imimposemin function. The imimposemin function uses morphological reconstruction to eliminate all minima from an the image except the minima you specify.

To illustrate the process of imposing a minima, this code creates a simple image containing two primary regional minima and several other regional minima.

Creating a Marker Image

To obtain an image that emphasizes the two deepest minima and removes all others, create a marker image that pinpoints the two minima of interest. You can create the marker image by explicitly setting certain pixels to specific values or by using other morphological functions to extract the features you want to emphasize in the mask image.

This example uses imextendedmin to get a binary image that shows the locations of the two deepest minima.

Applying the Marker Image to the Mask

Now use imimposemin to create new minima in the mask image at the points specified by the marker image. Note how imimposemin sets the values of pixels specified by the marker image to the lowest value supported by the datatype (0 for uint8 values). imimposemin also changes the values of all the other pixels in the image to eliminate the other minima.

This figure illustrates in 1-D how imimposemin changes the profile of row 2 of the image.

Figure 9-8: Imposing a Minima


  Flood-Fill Operations Distance Transform