Main Content

imhmin

Suppress regional minima in image using H-minima transform

Description

J = imhmin(I,H) suppresses regional minima in the grayscale image I by using the H-minima transform. The H-minima transform decreases the depth of all regional minima by an amount up to H. As a result, the transform fully suppresses regional minima whose depth is less than H. Regional minima are connected pixels with the same intensity value, t, that are surrounded by pixels with an intensity value greater than t.

example

J = imhmin(I,H,conn) additionally specifies the connectivity value used to identify the regional minima in I.

Examples

collapse all

Create a 10-by-10 sample image. Add three regional minima, each consisting of an area of connected pixels surrounded by higher intensity values.

a = 10*ones(10,10);
a(2:4,2:4) = 7;  
a(6:8,6:8) = 2;
a(1:3,7:9) = 13;
a(2,8) = 10;

This image is a grayscale representation of the pixel values. The depth of each minimum depends on the surrounding pixel values.

Grayscale representation of the original pixel values, with callouts labeling the depth of each minimum as 3, 3, and 8.

Apply the H-minima transform that decreases the depth of regional minima by up to 4.

h = 4;
b = imhmin(a,h);

This image is a grayscale representation of the transformed image. The transform fully suppresses two of the minima. The transform partially suppresses the deepest minimum, and adds 4 to the intensity values of the pixels in that minimum.

Grayscale representation of the transformed pixel values

You can suppress shallow regional minima to avoid oversegmentation during watershed segmentation.

Load an RGB image of pears to segment. Convert the image to grayscale and display it. The center of each pear is bright, corresponding to a regional maximum.

RGB = imread("pears.png");
I = im2gray(RGB);
imshow(I)

Figure contains an axes object. The hidden axes object contains an object of type image.

In watershed segmentation, the image is analogous to a surface comprised of watershed lines and catchment basins. When water flows into the surface, it pools in the catchment basins. In a grayscale image, local minima are the catchment basins. To segment the pears, invert the image so the centers of the pears become regional minima.

Icomp = imcomplement(I);
imshow(Icomp)

Figure contains an axes object. The hidden axes object contains an object of type image.

Display the inverted image as a 3-D surface, in which the third dimension for each pixel is its intensity value. The deeper regions for each pear have spiky bottoms, indicating many shallow regional minima, like catchment basins into which water can pool.

surf(Icomp,EdgeColor="none")
colormap(gray)

Figure contains an axes object. The axes object contains an object of type surface.

Segment the unfiltered image and display the result as a label overlay. The image is oversegmented, meaning there are many small masks rather than one mask for each pear.

L = watershed(Icomp);
overlay = labeloverlay(I,L);
imshow(overlay)

Figure contains an axes object. The hidden axes object contains an object of type image.

Suppress the shallow minima by applying the H-minima transform. The value for h has been determined by using trial and error. Change the value to see how the h value affects the segmentation result.

h = 30;
Ifilt = imhmin(Icomp,h);

Display the filtered image as a 3-D surface.

surf(Ifilt,EdgeColor="none")
colormap(gray)

Figure contains an axes object. The axes object contains an object of type surface.

Segment the filtered image and display the result. The image contains approximately one mask for each pear in the foreground.

Lfilt = watershed(Ifilt);
overlayfilt = labeloverlay(I,Lfilt);
imshow(overlayfilt)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

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

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

H-minima transform, specified as a nonnegative scalar.

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

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

4

Pixels are connected if their edges touch. The neighborhood of a pixel are the adjacent pixels in the horizontal or vertical direction.

3-by-3 pixel neighborhood with four pixels connected to the center pixel

Current pixel is shown in gray.

8

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.

3-by-3 pixel neighborhood with 8 pixels connected to the center pixel

Current pixel is shown in gray.

Three-Dimensional Connectivities

6

Pixels are connected if their faces touch. The neighborhood of a pixel are the adjacent pixels in:

  • One of these directions: in, out, left, right, up, and down

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces of the center pixel

Current pixel is shown in gray.

18

Pixels are connected if their faces or edges touch. The neighborhood of a pixel are the adjacent pixels in:

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces and 12 pixels connected to the edges of the center pixel

Current pixel is center of cube.

26

Pixels are connected if their faces, edges, or corners touch. The neighborhood of a pixel are the adjacent pixels in:

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

  • A combination of three directions, such as in-right-up or in-left-down

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces, 12 pixels connected to the edges, and 8 pixels connected to the corners of the center pixel

Current pixel is center of cube.

For higher dimensions, imhmin 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 0s and 1s. 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

collapse all

Transformed image, returned as a numeric array of the same size and data type as I.

References

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

Extended Capabilities

Version History

Introduced before R2006a