Eroded Otsu-labeling#

This operation segments and labels an image using blurring, Otsu-thresholding, binary erosion and masked Voronoi-labeling.

After bluring and thresholding using Otsu’s method, iterative binary erosion is applied. Objects in the eroded image are labeled using connected component labeling and these labels are dilated to fit again into the initial binary image using masked-Voronoi labeling.

This function is similar to voronoi_otsu_labeling. It is intended to deal better in cases where labels of objects swapping into each other if objects are dense. Like when using Voronoi-Otsu-labeling, small objects may disappear when applying this operation.

This function is inspired by a similar implementation in Java by Jan Brocher (Biovoxxel) in the Biovoxxel toolbox. Big thanks 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)

We just crop out a 2D slice.

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

Parameter: number_of_erosions#

If the specified number of erosions is too small, sticky objects will be labeled together.

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

If too many erosions are configured, objects may disappear.

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

Parameter: outline_sigma#

With this outline, you can control the denoising before thresholding. If this value is too low, objects may have noisy edges and holes lead to more object-splits.

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

If this value is too high, object outlines may be not fitting to the original objects anymore.

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