表面上的连通组件标记#

本笔记本演示了如何根据连通性区分对象。

import napari_process_points_and_surfaces as nppas
import pyclesperanto_prototype as cle
import napari_simpleitk_image_processing as nsitk
from skimage.data import cells3d
import stackview

我们使用细胞核的3D图像…

image = cells3d()[:,1]
stackview.insight(image)
shape(60, 256, 256)
dtypeuint16
size7.5 MB
min0
max65535

…并对细胞核进行分割,得到一个3D二值图像。

labels = cle.voronoi_otsu_labeling(image, spot_sigma=9)
binary = cle.erode_labels(labels) > 0

stackview.insight(binary)
shape(60, 256, 256)
dtypeuint8
size3.8 MB
min0
max1

我们将这个二值图像转换为表面数据集。

surface = nppas.all_labels_to_surface(binary)
surface
nppas.SurfaceTuple
origin (z/y/x)[0. 0. 0.]
center of mass(z/y/x)34.703,124.973,131.513
scale(z/y/x)1.000,1.000,1.000
bounds (z/y/x)16.500...59.000
0.000...255.000
0.000...255.000
average size97.003
number of vertices151354
number of faces301006

通过对表面应用连通组件标记,我们可以识别连接的顶点/面,并区分那些不连接的。结果也是一个表面数据集,其中顶点值对应于这些对象所属的第n个标签。因此,你可以从这个表面的最大数值得出结论,这个图像中有38个细胞核。

surface_connected_components = nppas.connected_component_labeling(surface)
surface_connected_components.cmap = 'hsv'
surface_connected_components
nppas.SurfaceTuple
origin (z/y/x)[0. 0. 0.]
center of mass(z/y/x)34.703,124.973,131.513
scale(z/y/x)1.000,1.000,1.000
bounds (z/y/x)16.500...59.000
0.000...255.000
0.000...255.000
average size97.003
number of vertices151354
number of faces301006
min0
max38