二值图像上的Voronoi-Otsu标记#

Voronoi-Otsu标记算法也可以用于二值图像,得到类似于ImageJ中二值分水岭的结果。它可以分割粘连在一起的圆形物体。

from skimage.io import imread
from napari_segment_blobs_and_things_with_membranes import voronoi_otsu_labeling, threshold_otsu
import stackview

为了演示这一点,我们从一个二值图像开始。

blobs_image = imread("../../data/blobs.tif")
binary_image = threshold_otsu(blobs_image)

binary_image
nsbatwm made image
shape(254, 256)
dtypeint32
size254.0 kB
min0
max1

现在我们对二值图像应用Voronoi-Otsu标记。

label_image = voronoi_otsu_labeling(binary_image, spot_sigma=3.5)

label_image
nsbatwm made image
shape(254, 256)
dtypeint32
size254.0 kB
min0
max67

练习#

下面你可以看到ImageJ中分水岭的结果。你需要如何修改上面的label_image结果,使其再次变成像ImageJ结果那样的二值图像?

binary_watershed_imagej = imread("../../data/blobs_otsu_watershed.tif")

stackview.insight(binary_watershed_imagej)
shape(254, 256)
dtypeuint8
size63.5 kB
min0
max255