Visit the wiki pages to find some additional documentation and instructions on how view an interactive verson of these notebooks using binder.

In [2]:
%matplotlib inline
In [1]:
import math
import numpy as np
import matplotlib.pyplot as plt

import skimage
from skimage import measure
from skimage import io
In [2]:
print(skimage.__version__)
0.16.2

Working with label images

Of course you would use a segmentation algorithm to obtain a label image. Here we simply load a precomputed label image.

In [3]:
image = io.imread("../images/nuclei-dapi.tif")
label_image = io.imread("../images/label-img.png")
In [4]:
fig, ax = plt.subplots(figsize=(8, 8))
plt.subplot(1,2,1)
plt.imshow(image, cmap='gray')
plt.subplot(1,2,2)
plt.imshow(label_image)
plt.show()
In [5]:
labels, N = measure.label(label_image, return_num=True)
print (N)
32

Measure region properties¶

In [6]:
props = measure.regionprops(labels, intensity_image=image)

Centroid of the region returned as (row, col). For example: region 29 corresponds to the red region in the bottom left corner.

Consult the regionprops documentation to see what measurements can be extracted. Here are only a few examples.

In [8]:
r = 15
print(props[r].centroid)
print(props[r].eccentricity)
print(props[r].orientation)
print(props[r].mean_intensity)
(141.79769736842104, 230.54605263157896)
0.9220335832126361
0.3724949574896717
56.34375
In [ ]: