imhmax
Suppress regional maxima in image using H-maxima transform
Description
suppresses regional maxima in the grayscale image J
= imhmax(I
,H
)I
by using the
H-maxima transform. The H-maxima transform decreases the height of all regional
maxima by an amount up to H
. As a result, the transform fully
suppresses regional maxima whose height is less than H
.
Regional maxima are connected pixels with the same
intensity value, t, that are surrounded by pixels with an
intensity value less than t.
Examples
Calculate H-Maxima Transform
Create a sample 10-by-10 image. Add two regional maxima, each consisting of an area of connected pixels surrounded by lower intensity values.
a = 10*ones(10,10); a(2:4,2:4) = 13; a(6:8,6:8) = 18;
This image is a grayscale representation of the pixel values. The height of each maximum depends on the surrounding pixel values.
Apply the H-maxima transform that decreases the height of regional maxima by up to 4.
b = imhmax(a,4);
This image is a grayscale representation of the transformed image. The transform fully suppresses one of the maxima. The transform partially suppresses the taller maximum, and subtracts 4 from the intensity values of the pixels in that maximum.
Find Brightest Intensity Peaks in Image Using H-Maxima Transform
You can suppress small regional maxima to identify the brightest peaks in an image.
Read a grayscale image of snowflakes into the workspace and display it.
I = imread("snowflakes.png");
imshow(I,InitialMagnification=200)
Find the regional maxima in the image.
regmax = imregionalmax(I);
Display a mask of the regional maxima pixels as an overlay on the original image. The regional maxima correspond to shallow intensity fluctuations, rather than the snowflakes.
overlay = imoverlay(I,regmax,"green");
imshow(overlay,InitialMagnification=200)
Apply the H-maxima transform to remove the shallow intensity peaks. Display the filtered image.
h = 75; B = imhmax(I,h); imshow(B,InitialMagnification=200)
Find the regional maxima of the filtered image. Display a mask of the maxima as an overlay on the original image.
regmaxfilt = imregionalmax(B);
overlayfilt = imoverlay(I,regmaxfilt,"green");
imshow(overlayfilt,InitialMagnification=200)
Note that you can alternatively use the imextendedmax
function to apply the H-maxima transform and calculate the regional maxima in one step.
Input Arguments
I
— Input image
numeric array
Input image, specified as a numeric array of any dimension.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
H
— H-maxima transform
nonnegative scalar
H-maxima transform, specified as a nonnegative scalar.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
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, imhmax
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: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
J
— Transformed image
numeric array
Transformed image, returned as a numeric array of the same size and class
as I
.
References
[1] Soille, P. Morphological Image Analysis: Principles and Applications. Springer-Verlag, 1999, pp. 170-171.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
imhmax
supports the generation of C code (requires MATLAB® Coder™). Note that if you choose the genericMATLAB Host Computer
target platform,imhmax
generates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Types of Code Generation Support in Image Processing Toolbox.When generating code, the optional third input argument,
conn
, must be a compile-time constant.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
When generating code, the optional third input argument,
conn
, must be a compile-time constant.
Version History
Introduced before R2006a
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)