Documentation

imhmax

H-maxima transform

Syntax

  • I2 = imhmax(I,h) example
  • I2 = imhmax(I,h,conn)

Description

example

I2 = imhmax(I,h) suppresses all maxima in the intensity image I whose height is less than h, where h is a scalar. Regional maxima are connected components of pixels with a constant intensity value, and whose external boundary pixels all have a lower value. By default, imhmax uses 8-connected neighborhoods for 2-D images, and 26-connected neighborhoods for 3-D images. For higher dimensions, imhmax uses conndef(ndims(I),'maximal').

This function supports code generation (see Tips).

I2 = imhmax(I,h,conn) computes the H-maxima transform, where conn specifies the connectivity.

Examples

collapse all

Calculate H-Maxima Transform

Create simple sample array of zeros.

a = zeros(10,10);

Create several maxima.

a(2:4,2:4) = 3;  % maxima 3 higher than surround
a(6:8,6:8) = 8;  % maxima 8 higher than surround

a
a =

     0     0     0     0     0     0     0     0     0     0
     0     3     3     3     0     0     0     0     0     0
     0     3     3     3     0     0     0     0     0     0
     0     3     3     3     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     8     8     8     0     0
     0     0     0     0     0     8     8     8     0     0
     0     0     0     0     0     8     8     8     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0

Calculate the maxima. Only the maxima higher than 4 survive.

b = imhmax(a,4); 
b =

     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     4     4     4     0     0
     0     0     0     0     0     4     4     4     0     0
     0     0     0     0     0     4     4     4     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0

Input Arguments

collapse all

I — Input imagenonsparse numeric array of any dimension

Input array, specified as a nonsparse numeric array of any dimension.

Example: I = imread(‘glass.png'); BW = imhmax(I,80);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

h — h-maxima transformnonnegative scalar

h-maxima transform, specified as a nonnegative scalar.

Example: b = imhmax(a,4);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

conn — Connectivity8 (default) | 4 | 6 | 18 | 26 | 3-by-3-by- ...-by-3 matrix of zeroes and ones

Connectivity, specified as a one of the scalar values in the following table. By default, imhmax uses 8-connected neighborhoods for 2-D images and 26-connected neighborhoods for 3-D images. For higher dimensions, imhmax uses conndef(numel(size(I)),'maximal'). Connectivity can be defined in a more general way for any dimension by using for conn a 3-by-3-by- ...-by-3 matrix of 0s and 1s. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric around its center element.

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

Example: b = imhmax(a,4,4);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

I2 — Transformed imagenonsparse numeric array of any class

Transformed image, returned as a nonsparse numeric array of any class, the same size as I.

More About

collapse all

Tips

  • This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function 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 Understanding Code Generation with Image Processing Toolbox.

    When generating code, the optional third input argument, conn, must be a compile-time constant.

References

[1] Soille, P., Morphological Image Analysis: Principles and Applications, Springer-Verlag, 1999, pp. 170-171.

Was this topic helpful?