计算其他标签图像中的近邻标签数#
import numpy as np
import pyclesperanto_prototype as cle
cle.get_device()
<gfx90c on Platform: AMD Accelerated Parallel Processing (2 refs)>
我们的起点是一个标签图像和另一个标签图像,其中第一个图像中的一些标签是从中选择的。
label_image = cle.artificial_tissue_2d()
cle.imshow(label_image, labels=True)
random_vector = np.random.random((1, int(label_image.max() + 1)))
sparse_labels = cle.exclude_labels_with_values_out_of_range(random_vector, label_image, minimum_value_range=0, maximum_value_range=0.3)
cle.imshow(sparse_labels, labels=True)
现在,我们对label_image中的每个标签计算在sparse_labels图像中与其相邻的标签数量。我们使用质心距离来测量距离。
count_map = cle.proximal_other_labels_count_map(label_image, sparse_labels, maximum_distance=25)
cle.imshow(count_map)