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


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


用法:

skimage.morphology.diameter_opening(image, diameter_threshold=8, connectivity=1, parent=None, tree_traverser=None)

执行图像的直径开口。

直径开口会移除最大扩展小于diameter_threshold 的图像的所有明亮结构。最大扩展定义为边界框的最大扩展。该运算符也称为边界框打开。在实践中,结果类似于形态开口,但不会去除细长结构。

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

参数

imagendarray

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

diameter_threshold无符号int

最大扩展参数(像素数)。默认值为 8。

connectivity无符号 int 可选

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

parentndarray,int64,可选

表示图像的最大树的父图像。每个像素的值是其父级在 raveled 数组中的索引。

tree_traverser一维数组,int64,可选

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

返回

outputndarray

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

参考

1

Walter, T., & Klein, J.-C. (2002). Automatic Detection of Microaneurysms in Color Fundus Images of the Human Retina by Means of the Bounding Box Closing. In A. Colosimo, P. Sirabella, A. Giuliani (Eds.), Medical Data Analysis. Lecture Notes in Computer Science, vol 2526, pp. 210-220. Springer Berlin Heidelberg. DOI:10.1007/3-540-36104-9_23

2

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 = 20 - 0.2*((x - w/2)**2 + (y-w/2)**2)
>>> f[2:3,1:5] = 40; f[2:4,9:11] = 60; f[9:11,2:4] = 80
>>> f[9:10,9:11] = 100; f[10,10] = 100
>>> f = f.astype(int)

我们可以计算直径开口:

>>> open = diameter_opening(f, 3, connectivity=1)

去除最大延伸为 2 或更少的峰。其余峰的最大延伸都至少为 3。

相关用法


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