This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.



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


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.



Two-dimensional connectivities


4-connected neighborhood


8-connected neighborhood

Three-dimensional connectivities


6-connected neighborhood


18-connected neighborhood


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.


collapse all

This example shows how to modify an image so that one area is always a regional minimum.

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

mask = imread('glass.png');

Create 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. The resulting image is called the marker image.

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

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

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

Impose the regional minimum on the input image using the imimposemin function. Note how all the dark areas of the original image, except the marked area, are lighter.

K = imimposemin(mask,marker);

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);
title('Regional Minima in Original Image')

BW2 = imregionalmin(K);
title('Regional Minima After Processing')


imimposemin uses a technique based on morphological reconstruction.

Introduced before R2006a

Was this topic helpful?