Documentation Center

  • Trial Software
  • Product Updates

imimposemin

Impose minima

Syntax

I2 = imimposemin(I,BW)
I2 = imimposemin(I,BW,conn)

Description

I2 = imimposemin(I,BW) modifies the intensity image I using morphological reconstruction so it only has regional minima wherever BW is nonzero. BW is a binary image the same size as I.

By default, imimposemin uses 8-connected neighborhoods for 2-D images and 26-connected neighborhoods for 3-D images. For higher dimensions, imimposemin uses conndef(ndims(I),'minimum').

I2 = imimposemin(I,BW,conn) specifies the connectivity, where conn can have any of the following scalar values.

Value

Meaning

Two-dimensional connectivities

4

4-connected neighborhood

8

8-connected neighborhood

Three-dimensional connectivities

6

6-connected neighborhood

18

18-connected neighborhood

26

26-connected neighborhood

Connectivity can also be defined in a more general way for any dimension by using for conn a 3-by-3-by-...-by-3 matrix of 0's and 1's. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric about its center element.

Class Support

I can be of any nonsparse numeric class and any dimension. BW must be a nonsparse numeric array with the same size as I. I2 has the same size and class as I.

Examples

Modify an image so that it only has regional minima at one location.

  1. Read an image and display it. This image is called the mask image.

    mask = imread('glass.png');
    imshow(mask)

  2. Create the marker image that will be used to process the mask image.

    The example creates a binary image that is the same size as the mask image and sets a small area of the binary image to 1. These pixels define the location in the mask image where a regional minimum will be imposed.

    marker = false(size(mask));
    marker(65:70,65:70) = true;

    To show where these pixels of interest fall on the original image, this code superimposes the marker over the mask. The small white square marks the spot. This code is not essential to the impose minima operation.

    J = mask;
    J(marker) = 255;
    figure, imshow(J); title('Marker Image Superimposed on Mask');

  3. Impose the regional minimum on the input image using the imimposemin function.

    The imimposemin function uses morphological reconstruction of the mask image with the marker image to impose the minima at the specified location. Note how all the dark areas of the original image, except the marked area, are lighter.

    K = imimposemin(mask,marker);
    figure, imshow(K);

  4. To illustrate how this operation removes all minima in the original image except the imposed minimum, compare the regional minima in the original image with the regional minimum in the processed image. These calls to imregionalmin return binary images that specify the locations of all the regional minima in both images.

    BW = imregionalmin(mask);
    figure, imshow(BW);  
    title('Regional Minima in Original Image');
    BW2 = imregionalmin(K);
    figure, imshow(BW2); 
    title('Regional Minima After Processing');

More About

expand all

Algorithms

imimposemin uses a technique based on morphological reconstruction.

See Also

| |

Was this topic helpful?