Edges of labels#

When processing biological objects in image such as cells and nuclei, it may make sense to identify all pixels that lie on the surface of an object. This notebook demonstrates how to select pixels on the border of nuclei, just in case we would like to measure intensity in the nuclear envelope.

import pyclesperanto_prototype as cle
import numpy as np
from skimage.io import imread
image = cle.asarray(imread("../../data/mitosis_mod.tif")[0:40,25:65])
image
cle._ image
shape(40, 40)
dtypefloat32
size6.2 kB
min12.0
max255.0

We then segment the nuclei.

label_image = cle.voronoi_otsu_labeling(image, spot_sigma=2, outline_sigma=1)
label_image
cle._ image
shape(40, 40)
dtypeuint32
size6.2 kB
min0.0
max4.0

From the nuclei label image we can extract another label image which contains all pixels that are on the edge of the labels.

edge_label_image = cle.reduce_labels_to_label_edges(label_image)
edge_label_image
cle._ image
shape(40, 40)
dtypeuint32
size6.2 kB
min0.0
max4.0

In case one wanted to measure in thicker areas along the borders, we could expand the borders.

thicker_edges = cle.dilate_labels(edge_label_image, radius=1)
thicker_edges
cle._ image
shape(40, 40)
dtypeuint32
size6.2 kB
min0.0
max4.0

For visualization purposes we can also view the original image with the label borders on top.

cle.imshow(image, continue_drawing=True)
cle.imshow(edge_label_image, alpha=0.6, labels=True)
../_images/95c99caf4314e3b3a7289336b4525ed49dcdc66beeb894e8b8d4b85964474e2b.png