Python3.x中的“bwlabeln(有18个和26个相连的邻居)”是什么意思?

2024-04-19 21:16:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用了Matlab的bwlabeln来处理带有18-connected neighborhood的三维连接词,代码如下:

[labeledImage, ~] = bwlabeln(maskImageVolume, 18); # maskImageVolume is 3D. e.g.:(200, 200, 126)

在Python中相当于它的是:

^{pr2}$

然而,Matlab中的bwlabeln支持Three-dimensional connectives(有18和26个连通邻域),而{}只支持4- or 8-“connectivity”。在

在Python中,18 and 26-connected neighborhoodbwlabeln等价于什么?在


Tags: or代码is邻域threematlabconnecteddimensional
1条回答
网友
1楼 · 发布于 2024-04-19 21:16:30

参数neighbors^{}状态文档:

neighbors : {4, 8}, int, optional
Whether to use 4- or 8-“connectivity”. In 3D, 4-“connectivity” means connected pixels have to share face, whereas with 8-“connectivity”, they have to share only edge or vertex.
Deprecated, use connectivity instead.

对于参数connectivity

connectivity : int, optional
Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor. Accepted values are ranging from 1 to input.ndim. If None, a full connectivity of input.ndim is used.

这意味着,在3D中,连接性可以是1、2或3,表示6、18或26个邻居。在

回顾文档的各个版本,scikit映像0.11中似乎引入了这种语法(0.10没有)。在

对于你的情况,有18个相连的邻居:

labeledImage = measure.label(maskImageVolume, connectivity=2) 

相关问题 更多 >