Zähle proximale Labels in einem anderen Label-Bild#
import numpy as np
import pyclesperanto_prototype as cle
cle.get_device()
<gfx90c on Platform: AMD Accelerated Parallel Processing (2 refs)>
Unser Ausgangspunkt ist ein Label-Bild und ein weiteres Label-Bild, aus dem einige der Labels im ersten Bild ausgewählt sind.
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)

Wir zählen nun für jedes Label in label_image
, wie viele Labels im sparse_labels
-Bild in der Nähe sind. Zur Messung der Entfernung verwenden wir die Schwerpunktdistanz.
count_map = cle.proximal_other_labels_count_map(label_image, sparse_labels, maximum_distance=25)
cle.imshow(count_map)
