J = imimposemin(I,BW)
J = imimposemin(I,BW,conn)
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'); imshow(mask)
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; figure imshow(J) 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); figure imshow(K)
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 subplot(1,2,1) imshow(BW) title('Regional Minima in Original Image') BW2 = imregionalmin(K); subplot(1,2,2) imshow(BW2) title('Regional Minima After Processing')
I— Grayscale mask image
Grayscale mask image, specified as a numeric array of any dimension.
BW— Binary marker image
Binary marker image, specified as a numeric or logical array of the same size as the
grayscale mask image
conn— Pixel connectivity
26| 3-by-3-by- ... -by-3 matrix of
Pixel connectivity, specified as one of the values in this table. The default
8 for 2-D images, and
26 for 3-D
Pixels are connected if their edges touch. The neighborhood of a pixel are the adjacent pixels in the horizontal or vertical direction.
Pixels are connected if their edges or corners touch. The neighborhood of a pixel are the adjacent pixels in the horizontal, vertical, or diagonal direction.
Pixels are connected if their faces touch. The neighborhood of a pixel are the adjacent pixels in:
Pixels are connected if their faces or edges touch. The neighborhood of a pixel are the adjacent pixels in:
Pixels are connected if their faces, edges, or corners touch. The neighborhood of a pixel are the adjacent pixels in:
For higher dimensions,
imimposemin uses the default value
imimposemin uses a technique based on morphological