imimposemin
Impose minima
Description
Examples
Impose Regional Minimum at One Location
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')
Input Arguments
I
— Grayscale mask image
numeric array
Grayscale mask image, specified as a numeric array of any dimension.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
BW
— Binary marker image
numeric array | logical array
Binary marker image, specified as a numeric or logical array of the same size as the
grayscale mask image I
. For numeric input,
any nonzero pixels are considered to be 1
(true
).
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
conn
— Pixel connectivity
4
| 8
| 6
| 18
| 26
| 3-by-3-by- ... -by-3 matrix of 0
s and
1
s
Pixel connectivity, specified as one of the values in this table. The default
connectivity is 8
for 2-D images, and 26
for 3-D
images.
Value | Meaning | |
---|---|---|
Two-Dimensional Connectivities | ||
| Pixels are connected if their edges touch. The neighborhood of a pixel are the adjacent pixels in the horizontal or vertical direction. |
Current pixel is shown in gray. |
| 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. |
Current pixel is shown in gray. |
Three-Dimensional Connectivities | ||
| Pixels are connected if their faces touch. The neighborhood of a pixel are the adjacent pixels in:
|
Current pixel is shown in gray. |
| Pixels are connected if their faces or edges touch. The neighborhood of a pixel are the adjacent pixels in:
|
Current pixel is center of cube. |
| Pixels are connected if their faces, edges, or corners touch. The neighborhood of a pixel are the adjacent pixels in:
|
Current pixel is center of cube. |
For higher dimensions, imimposemin
uses the default value
.conndef
(ndims(I),"maximal")
Connectivity can also be
defined in a more general way for any dimension by specifying 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. See Specifying Custom Connectivities for more information.
Data Types: double
| logical
Output Arguments
J
— Reconstructed image
numeric array
Reconstructed image, returned as a numeric or logical array of the same size and
data type as I
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
imimposemin
supports the generation of C code (requires MATLAB® Coder™). For more information, see Code Generation for Image Processing.imimposemin
only supports 2-D mask and marker images.The
conn
argument must be a compile-time constant and the only connectivities supported are4
or8
. You can also specify connectivity as a 3-by-3 matrix, but it can only be[0 1 0;1 1 1;0 1 0]
orones(3)
.
Version History
Introduced before R2006aR2023b: Support for C code generation
imimposemin
now supports the generation of
C code (requires MATLAB
Coder).
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)