import numpy as np
import pyclesperanto_prototype as cle
cle.select_device("RTX")
<NVIDIA GeForce RTX 3050 Ti Laptop GPU on Platform: NVIDIA CUDA (1 refs)>
def generate_centroid_distance_matrix(label_image1, label_image2):
centroids1 = cle.centroids_of_labels(label_image1)
if label_image1 is label_image2:
centroids2 = centroids1
else:
centroids2 = cle.centroids_of_labels(label_image1)
return cle.generate_distance_matrix(centroids1, centroids2)
image = np.asarray([[0,2,1,4,4],
[0,2,3,4,4]])
generate_centroid_distance_matrix(image, image)
cl.Array([[0. , 0. , 0. , 0. , 0. ], [0. , 0. , 1.1180339, 1. , 1.5811388], [0. , 1.1180339, 0. , 1.1180339, 2.4999998], [0. , 1. , 1.1180339, 0. , 1.5811388], [0. , 1.5811388, 2.4999998, 1.5811388, 0. ]], dtype=float32)