Interactive pixel classification and object segmentation in Napari#
In this exercise we will train a Random Forest Classifier for pixel classification and convert the result in an instance segmentation. We will use the napari plugin napari-accelerated-pixel-and-object-classification.
Open a terminal window and activate your conda environment:
conda activate devbio-napari-env
Afterwards, start up Napari:
Load the “Blobs” example dataset from the menu
File > Open Sample > clEsperanto > Blobs (from ImageJ)
Pixel classification and Object Segmentation in Napari#
For segmenting objects, we can use the Object Segmentation tool in APOC. Under the hood it uses a pixel classifier and connected component labeling. The following procedure is also shown in this video.
Start the object segmentation from the
Tools > Segmentation / Labeling > Object Segmentation (APOC) menu.
Add a new labels layer by clicking on this button:
Change the brush size to a small number such as 2 or 3.
Click on the
Paint brush button.
Start annotating the
background region where there is no object.
Increase the label that is drawn by one.
Draw an annotation within the objects of interest. Draw background and object annotation close by each other. The closer these two annotations are drawn, the smaller is the degree of freedom the computer has when optimizing the model later.
Object segmentation user interface on the right, select the image/channel that should be processed.
Also select the annotation label image you have just drawn.
Train. A label image should show up.
If the segmentation works well, consider backing up the
ObjectSegmenter.cl file that has been saved.
If you didn’t change the file location before training, it will be located in the folder from where you started napari on the command line.