Quantitative maps from neighbor statistics#

This notebook illustrates how to generate quantitative maps based on neighbor statistics using image processing libraries.

import pyclesperanto_prototype as cle
import numpy as np
from numpy import random
from skimage.io import imread
import matplotlib

The example image “maize_clsm.tif” was taken from the repository mathematical_morphology_with_MorphoLibJ and is licensed by David Legland under CC-BY 4.0 license.

intensity_image = imread('../../data/maize_clsm.tif')
cle.imshow(intensity_image)
../_images/3c7dbb24e135a5fdcac44c238f901a435d0a437648d9e5ca90e5f642163575dd.png

Starting point: Label map#

First, we perform a segmentation process to obtain a labeled map of the cells using thresholding and Voronoi labeling.

binary = cle.binary_not(cle.threshold_otsu(intensity_image))
cells = cle.voronoi_labeling(binary)

cle.imshow(cells, labels=True)
../_images/e6bc3d4731e9f46f39bdcb41b58b63c1c61a1a5d7cd0b073514cc058a99d2f0e.png

Nearest neighbor distance maps#

We then compute maps of the average distance to the nearest neighbors for each labeled cell.

average_distance_of_n_closest_neighbors_map = cle.average_distance_of_n_closest_neighbors_map(cells, n=1)
cle.imshow(average_distance_of_n_closest_neighbors_map, color_map='jet')
../_images/8bb945638276e2ca353c0e0d5f085b57f72c428e6723fb67b51d1ca281382399.png
average_distance_of_n_closest_neighbors_map = cle.average_distance_of_n_closest_neighbors_map(cells, n=5)
cle.imshow(average_distance_of_n_closest_neighbors_map, color_map='jet')
../_images/f27150c46a872ae2351493aabbdedf24df3a24b526834d3f44c33ef55f90b6c8.png

Touching neighbor distance map#

Finally, we create a map that shows the average distance to touching neighbors for each cell.

average_neighbor_distance_map = cle.average_neighbor_distance_map(cells)
cle.imshow(average_neighbor_distance_map, color_map='jet')
../_images/855cd026e1cdd43679d507d7debcda338aabd772594d8e6346471efae624c824.png