In this notebook we use stackview.annotate
to create a label image with manual annotations.
import stackview
import numpy as np
from skimage.data import cells3d
The cells3d dataset from scikit-image serves as example image. One of the two channels shown nuclei.
image = cells3d()[:,1]
stackview.insight(image)
|
|
Before annotating the nuclei, we create an empty label image of type unsigned 32-bit integer. This type is necessary so that stackview views the image correctly as labels. Compatible types are: int32
,uint32
,int64
,uint64
.
labels = np.zeros(image.shape).astype(np.uint32)
The function stackview.annotate
creates a user interface where we can draw labels on top of the original image. Click and drag for drawing. Hold the ALT
key for erasing.
stackview.annotate(image, labels)
VBox(children=(HBox(children=(HBox(children=(VBox(children=(ImageWidget(height=256, width=256),)),)), VBox(chiā¦
You can also annotate in a different plane than the Z-plane by providing an axis (0=z,1=y,2=x).
stackview.annotate(image, labels, axis=1)
Once annotations are drawn, we can view them as usual using the insight()
function.
stackview.insight(labels)
Just for fun we use the apoc library to create an instance segmentation of nuclei from our annotation.
import apoc
segmenter = apoc.ObjectSegmenter(positive_class_identifier=1)
features = apoc.PredefinedFeatureSet.small_quick.value
segmenter.train(image=image, ground_truth=labels, features=features)
result = segmenter.predict(image)
stackview.insight(result[30])