import numpy as np
import pyclesperanto_prototype as cle
from pyclesperanto_prototype import Image, plugin_function
cle.select_device("RTX")
<NVIDIA GeForce RTX 3050 Ti Laptop GPU on Platform: NVIDIA CUDA (1 refs)>
labels = cle.asarray([
[0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 2, 2, 0],
[0, 1, 1, 1, 2, 2, 0],
[0, 0, 3, 3, 3, 3, 0],
[0, 0, 4, 4, 4, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
])
labels = cle.scale(labels, factor_x=10, factor_y=10, auto_size=True).astype(np.uint32)
labels
cle._ image
|
touch_count_matrix = cle.generate_touch_count_matrix(labels)
print(touch_count_matrix)
[[ 0 70 50 30 50] [70 0 10 20 0] [50 10 0 20 0] [30 20 20 0 30] [50 0 0 30 0]]
touch_portion_matrix = cle.generate_touch_portion_matrix(labels)
print(touch_portion_matrix)
[[0. 0.7 0.625 0.29999998 0.625 ] [0.35 0. 0.125 0.19999999 0. ] [0.25 0.09999999 0. 0.19999999 0. ] [0.14999999 0.19999999 0.25 0. 0.375 ] [0.25 0. 0. 0.29999998 0. ]]
cle.is_matrix_symmetric(touch_count_matrix)
True
cle.is_matrix_symmetric(touch_portion_matrix)
False
cle.generate_n_most_touching_neighbors_matrix(touch_count_matrix, n=1)
cle.array([[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 1. 0.]], dtype=float32)
cle.generate_n_most_touching_neighbors_matrix(touch_portion_matrix, n=1)
cle.array([[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 1. 0.]], dtype=float32)
cle.generate_n_most_touching_neighbors_matrix(touch_portion_matrix, n=2)
cle.array([[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 1. 0. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 1. 0.]], dtype=float32)
mesh = cle.draw_mesh_between_n_most_touching_labels(labels, n=1)
cle.imshow(labels, labels=True, continue_drawing=True)
cle.imshow(mesh, alpha=0.5)
mesh = cle.draw_mesh_between_n_most_touching_labels(labels, n=2)
cle.imshow(labels, labels=True, continue_drawing=True)
cle.imshow(mesh, alpha=0.5)
sd_map = cle.standard_deviation_of_n_most_touching_neighbors_map(labels, labels, n=2)
sd_map
cle._ image
|
min_map = cle.minimum_of_n_most_touching_neighbors_map(labels, labels, n=2)
min_map
cle._ image
|
max_map = cle.maximum_of_n_most_touching_neighbors_map(labels, labels, n=1)
max_map
cle._ image
|
mean_map = cle.mean_of_n_most_touching_neighbors_map(labels, labels, n=1)
mean_map
cle._ image
|
mode_map = cle.mode_of_n_most_touching_neighbors_map(labels, labels, n=1)
mode_map
cle._ image
|
cle.generate_n_most_touching_neighbors_matrix(touch_count_matrix, n=2)
cle.array([[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 1. 0. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 1. 0.]], dtype=float32)
cle.draw_mesh_between_n_most_touching_labels(labels, n=2)
cle._ image
|
cle.generate_n_most_touching_neighbors_matrix(touch_count_matrix, n=2)
cle.array([[0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 1. 0. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 1. 0.]], dtype=float32)
cle.draw_mesh_between_n_most_touching_labels(labels, n=3)
cle._ image
|