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

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


from skimage import io
from skimage import filters, measure
from skimage.filters import threshold_otsu

%matplotlib inline

Global Otsu Threshold - Example 1

In [8]:
image = io.imread("../images/nuclei-dapi.tif")
In [9]:
threshold = threshold_otsu(image)
print(threshold) 
binary = ~(image <= threshold)
33
In [10]:
fig, ax = plt.subplots(figsize=(10, 10))
plt.subplot(1,2,1)
plt.imshow(image, cmap='gray')
plt.subplot(1,2, 2)
plt.imshow(binary, cmap='gray')
plt.show()

Apply connected component labelling

In [17]:
all_labels = measure.label(binary)
blob_labels = measure.label(binary, background=0)
In [18]:
fig, ax = plt.subplots(figsize=(10, 10))
plt.imshow(blob_labels, cmap='nipy_spectral')
Out[18]:
<matplotlib.image.AxesImage at 0x7ffe64af8b10>

Generate labels from the labelled components

In [19]:
labels, N = measure.label(blob_labels, return_num=True)
print (N)
33
In [ ]: