主要内容

imreconstruct

R2026b

形态学重新构造

描述

J = imreconstruct(marker,mask) 在图像 mask 下执行图像 marker 的形态学重新构造,并在 J 中返回重新构造的结果。marker 的元素必须小于或等于 mask 的对应元素。如果 marker 中的值大于 mask 中的对应元素,则 imreconstruct 在开始过程之前将值裁剪到 mask 水平。

示例

J = imreconstruct(marker,mask,conn) 使用指定的连通 conn 执行形态学重新构造。

示例

全部折叠

读取并显示灰度图像。

I = imread('snowflakes.png');
imshow(I)

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

调整图像的对比度以创建掩膜图像并显示结果。

mask = adapthisteq(I);
imshow(mask)

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

使用形态学腐蚀创建一个标识图像中高强度对象的标记图像并显示结果。

se = strel('disk',5);
marker = imerode(mask,se);
imshow(marker)

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

使用标记图像以识别掩膜中的高强度对象,对掩膜图像执行形态学开运算。显示结果。

obr = imreconstruct(marker,mask);
imshow(obr,[])

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

将一个逻辑图像读入工作区并显示它。这是掩膜图像。

mask = imread('text.png');
figure
imshow(mask)

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

创建一个标识图像中要通过分割提取的目标的标记图像。对于此示例,识别单词“watershed”中的“w”。

marker = false(size(mask));
marker(13,94) = true;

使用标记图像执行掩膜图像的分割。

im = imreconstruct(marker,mask);
figure
imshow(im)

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

输入参数

全部折叠

输入图像,指定为数值或逻辑数组。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

掩膜图像,指定为与 marker 大小和数据类型相同的数值或逻辑数组。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

像素连通性,指定为下表中的值之一。对于二维图像,默认连通性是 8,对于三维图像,默认连通性是 26。

值

意义

二维连通

4

如果像素的边缘相互接触,则这些像素具有连通性。像素的邻域是水平或垂直方向上的相邻像素。

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

当前像素以灰色显示。

8

如果像素的边缘或角相互接触,则这些像素具有连通性。像素的邻域是水平、垂直或对角线方向上的相邻像素。

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

当前像素以灰色显示。

三维连通

6

如果像素的面接触,则这些像素具有连通性。像素的邻域是符合以下条件的相邻像素:

  • 在所列方向之一上连通:内、外、左、右、上、下

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

当前像素以灰色显示。

18

如果像素的面或边缘接触,则这些像素具有连通性。像素的邻域是符合以下条件的相邻像素:

  • 在所列方向之一上连通:内、外、左、右、上、下

  • 在两个方向的组合上连通,如右下或内上

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

当前像素是立方体的中心。

26

如果像素的面、边缘或角接触,则这些像素具有连通性。像素的邻域是符合以下条件的相邻像素:

  • 在所列方向之一上连通:内、外、左、右、上、下

  • 在两个方向的组合上连通,如右下或内上

  • 在三个方向的组合上连通,如内右上或内左下

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

当前像素是立方体的中心。

对于更高的维度,imreconstruct 使用默认值 conndef(ndims(marker),"maximal")。

也可以通过指定由 0 和 1 组成的 3×3×...×3 矩阵,以更通用的方式来定义任意维度的连通性。值为 1 的元素定义相对于 conn 的中心元素的邻域位置。请注意,conn 必须关于其中心元素对称。有关详细信息,请参阅指定自定义连通性。

数据类型: double | logical

输出参量

全部折叠

重新构造图像,以与输入图像大小相同的数值或逻辑数组形式返回(取决于输入图像)。

提示

算法

imreconstruct 使用 [1] 中所述的快速混合灰度重新构造算法。

参考

[1] Vincent, L., "Morphological Grayscale Reconstruction in Image Analysis: Applications and Efficient Algorithms," IEEE Transactions on Image Processing, Vol. 2, No. 2, April, 1993, pp. 176-201.

扩展功能

全部展开

版本历史记录

在 R2006a 之前推出

全部展开