当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python skimage.morphology.area_closing用法及代码示例


用法:

skimage.morphology.area_closing(image, area_threshold=64, connectivity=1, parent=None, tree_traverser=None)

执行图像的区域关闭。

区域闭合会移除表面小于 area_threshold 的图像的所有暗结构。对于每个像素,输出图像都大于或等于输入图像,并且所有局部最小值都至少具有 area_threshold 个像素的表面。

区域闭合类似于形态闭合,但它们不使用固定足迹,而是使用可变形的足迹,表面 = area_threshold。

在二进制情况下,区域关闭等价于remove_small_holes;因此,该算子扩展到灰度图像。

从技术上讲,此运算符基于图像的max-tree 表示。

参数

imagendarray

要计算area_closing 的输入图像。此图像可以是任何类型。

area_threshold无符号int

尺寸参数(像素数)。默认值任意选择为 64。

connectivity无符号 int 可选

邻里连通性。整数表示到达邻居的最大正交步数。在 2D 中,4 邻域为 1,8 邻域为 2。默认值为 1。

parentndarray,int64,可选

表示倒置图像的最大树的父图像。每个像素的值是其父级在 raveled 数组中的索引。有关详细信息,请参阅注释。

tree_traverser一维数组,int64,可选

有序像素索引(指的是散列数组)。像素被排序,使得每个像素都位于其父级之前(除了没有父级的根)。

返回

outputndarray

与输入图像具有相同形状和类型的输出图像。

注意

如果给函数一个max-tree表示(parent和tree_traverser),它们必须从这个函数的倒置图像中计算出来,即:>>> P, S = max_tree(invert(f)) > >> 关闭 = diameter_closing(f, 3, parent=P, tree_traverser=S)

参考

1

Vincent L., Proc. “Grayscale area openings and closings, their efficient implementation and applications”, EURASIP Workshop on Mathematical Morphology and its Applications to Signal Processing, Barcelona, Spain, pp.22-27, May 1993.

2

Soille, P., “Morphological Image Analysis: Principles and Applications” (Chapter 6), 2nd edition (2003), ISBN 3540429883. DOI:10.1007/978-3-662-05088-0

3

Salembier, P., Oliveras, A., & Garrido, L. (1998). Antiextensive Connected Operators for Image and Sequence Processing. IEEE Transactions on Image Processing, 7(4), 555-570. DOI:10.1109/83.663500

4

Najman, L., & Couprie, M. (2006). Building the component tree in quasi-linear time. IEEE Transactions on Image Processing, 15(11), 3531-3539. DOI:10.1109/TIP.2006.877518

5

Carlinet, E., & Geraud, T. (2014). A Comparative Review of Component Tree Computation Algorithms. IEEE Transactions on Image Processing, 23(9), 3885-3895. DOI:10.1109/TIP.2014.2336551

例子

我们创建一个图像(二次函数,中心有一个最小值,另外还有 4 个局部最小值。

>>> w = 12
>>> x, y = np.mgrid[0:w,0:w]
>>> f = 180 + 0.2*((x - w/2)**2 + (y-w/2)**2)
>>> f[2:3,1:5] = 160; f[2:4,9:11] = 140; f[9:11,2:4] = 120
>>> f[9:10,9:11] = 100; f[10,10] = 100
>>> f = f.astype(int)

我们可以计算闭合面积:

>>> closed = area_closing(f, 8, connectivity=1)

所有小的最小值都被删除,剩下的最小值至少为 8。

相关用法


注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.morphology.area_closing。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。