合并标签#
原则上,所有分割算法都有局限性。如果结果不理想,并且没有更好的分割算法可用,后处理标签可能是一种选择。有一些函数可用于根据标签的属性(如标签接触边缘的强度、成对组合标签的像素计数)来合并标签。
import pyclesperanto_prototype as cle
from napari_segment_blobs_and_things_with_membranes import local_minima_seeded_watershed
import numpy as np
cle.select_device("TX")
<NVIDIA GeForce RTX 3050 Ti Laptop GPU on Platform: NVIDIA CUDA (1 refs)>
合并接触的标签#
最简单的用例可能是合并相互接触的标记对象。
blobs = cle.imread("../../data/blobs.tif")
blobs_labels = cle.voronoi_otsu_labeling(blobs, spot_sigma=3)
blobs_labels
|
|
cle._ image
|
cle.merge_touching_labels(blobs_labels)
|
|
cle._ image
|
根据边界强度合并标签#
作为示例,我们使用了scikit-image中cells3d示例数据集的一个裁剪切片。
image = cle.imread("../../data/membranes_2d.tif")[30:130, 0:100]
image
|
|
cle._ image
|
在下面的例子中,我们图像中心的细胞被错误地分割为两个细胞:
labels = local_minima_seeded_watershed(image, spot_sigma=5, outline_sigma=0)
labels
|
|
nsbatwm made image
|
这可以通过合并边界强度低于给定阈值的细胞来纠正。
merged_labels = cle.merge_labels_with_border_intensity_within_range(image, labels, maximum_intensity=5000)
merged_labels
c:\structure\code\pyclesperanto_prototype\pyclesperanto_prototype\_tier3\_generate_touch_mean_intensity_matrix.py:30: UserWarning: generate_touch_mean_intensity_matrix is supposed to work with images of integer type only.
Loss of information is possible when passing non-integer images.
warnings.warn("generate_touch_mean_intensity_matrix is supposed to work with images of integer type only.\n" +
|
|
cle._ image
|