%matplotlib inline
import math
import numpy as np
import matplotlib.pyplot as plt
import skimage
from skimage import measure
from skimage import io
print(skimage.__version__)
Of course you would use a segmentation algorithm to obtain a label image. Here we simply load a precomputed label image.
image = io.imread("../images/nuclei-dapi.tif")
label_image = io.imread("../images/label-img.png")
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()
labels, N = measure.label(label_image, return_num=True)
print (N)
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.
r = 15
print(props[r].centroid)
print(props[r].eccentricity)
print(props[r].orientation)
print(props[r].mean_intensity)