侵蚀Otsu标记#

此操作使用模糊、Otsu阈值、二值侵蚀和掩模Voronoi标记来分割和标记图像。

在使用Otsu方法进行模糊和阈值处理后,应用迭代二值侵蚀。使用连通组件标记来标记侵蚀图像中的对象,然后使用掩模Voronoi标记将这些标签扩张以再次适应初始二值图像。

此函数类似于voronoi_otsu_labeling。它旨在更好地处理对象密集时标签相互交换的情况。与使用Voronoi-Otsu标记一样,应用此操作时小对象可能会消失。

这个函数的灵感来自Jan Brocher(Biovoxxel)在Biovoxxel工具箱中的类似Java实现。非常感谢Jan!

from skimage.data import cells3d
import pyclesperanto_prototype as cle
import napari_segment_blobs_and_things_with_membranes as nsbatwm
image = cells3d()
image.shape
(60, 2, 256, 256)

我们只截取一个2D切片。

nuclei = cle.asarray(image[30, 1])
nuclei
cle._ image
shape(256, 256)
dtypefloat32
size256.0 kB
min1091.0
max58327.0
labels = cle.eroded_otsu_labeling(nuclei, number_of_erosions=11, outline_sigma=4)
labels
cle._ image
shape(256, 256)
dtypeuint32
size256.0 kB
min0.0
max17.0

参数:number_of_erosions#

如果指定的侵蚀次数太少,粘连的对象将被标记为一体。

labels = cle.eroded_otsu_labeling(nuclei, number_of_erosions=5, outline_sigma=4)
labels
cle._ image
shape(256, 256)
dtypeuint32
size256.0 kB
min0.0
max16.0

如果配置的侵蚀次数太多,对象可能会消失。

labels = cle.eroded_otsu_labeling(nuclei, number_of_erosions=20, outline_sigma=4)
labels
cle._ image
shape(256, 256)
dtypeuint32
size256.0 kB
min0.0
max3.0

参数:outline_sigma#

通过这个轮廓,你可以控制阈值处理前的去噪。如果这个值太低,对象可能会有噪声边缘,孔洞会导致更多的对象分裂。

labels = cle.eroded_otsu_labeling(nuclei, number_of_erosions=5, outline_sigma=1)
labels
cle._ image
shape(256, 256)
dtypeuint32
size256.0 kB
min0.0
max37.0

如果这个值太高,对象轮廓可能不再适合原始对象。

labels = cle.eroded_otsu_labeling(nuclei, number_of_erosions=11, outline_sigma=10)
labels
cle._ image
shape(256, 256)
dtypeuint32
size256.0 kB
min0.0
max11.0