分割3D三维体素立方体

时间:2019-05-28 10:21:29

标签: python numpy machine-learning image-segmentation voxel

我正在尝试在30x30x30(转换为npy的binvox)多维数据集上执行分水岭分割。它可以具有两个功能,例如矩形通道和圆形通道。我想使用每个功能将多维数据集细分为两个不同的多维数据集。

我最终得到的numpy数组是二进制的,1是实心的,0是空心的。

我尝试使用与scikit-image库用于图像(连接的组件标记,然后进行分水岭分割)的方法相同。具有两个功能的基本文件失败。我也尝试了Connected Components 3D,然后尝试了scikit-image分水岭,但没有成果。

请参见下面的代码。

inf = np.load(path/to/npy)

D = ndimage.distance_transform_edt(inf)
localMax = peak_local_max(D, labels=inf, indices=False, min_distance=1)

# ccl
markers = ndimage.label(localMax)
# perform a connected component analysis on the local peaks, using 8-connectivity, then appy the Watershed algorithm

labels = watershed(-D, markers, mask=inf)

# loop over the unique labels returned by the Watershed algorithm

for label in np.unique(labels):
     if label == 0:
         continue
     mask = np.ones(inf.shape, dtype=np.int32)
     mask[labels == label] = 0
     np.save(path/to/save)

由于我一个人从事这项工作,因此可能需要更改我的思维过程。因此,如果有人可以指导我哪里做错了,那将真的很有帮助。

0 个答案:

没有答案