Connected component labeling
Prerequisites
Before starting this lesson, you should be familiar with:
Learning Objectives
After completing this lesson, learners should be able to:
Understand how objects in images are represented as a label mask image.
Apply connected component labeling to a binary image to create a label mask image.
Motivation
A main task of bioimage analysis is to detect objects in images. To do so one needs to be able to label pixels that are part of the same object in a way that this can be efficiently stored and processed by the computer. A prevalent way of doing this is connected component labeling, which is discussed in this module.
Concept map
Figure
Typically, one first categorise an image into background and foreground regions, which can be represented as a binary image. Such clusters in the segmented image are called connected components. The relation between two or more pixels is described by its connectivity. The next step is a connected components labeling, where spatially connected regions of foreground pixels are assigned (labeled) as being part of one region (object).
In an image, pixels are ordered in a squared configuration.
For performing a connected component analysis, it is important to define which pixels are considered direct neighbors of a pixel. This is called connectivity and defines which pixels are considered connected to each other.
Essentially the choice is whether or not to include diagonal connections.
Or, in other words, how many orthogonal jumps to you need to make to reach a neighboring pixel; this is 1 or an orthogonal neighbor and 2 for a diagonal neighbor.
This leads to the following equivalent nomenclatures:
- 2D: 1 connectivity = 4 connectivity
- 2D: 2 connectivity = 8 connectivity
- 3D: 1 connectivity = 6 connectivity
- 3D: 2 connectivity = 26 connectivity
Activities
2D connected component labeling
- Open image xy_8bit_binary__nuclei.tif.
- Create a label image by means of 4-connected connected components labeling.
- Apply a multi-color LUT.
- Repeat with 8-connected labeling and discuss the difference.
Show activity for:
ImageJ MorpholibJ Macro & GUI
skimage napari
Knime
3D connected component labeling
- Open image xyz_8bit_binary__spots.tif
- Inspect the pixel values of the label image and see what you can learn about the objects that are encoded in this image.
Show activity for:
ImageJ MorpholibJ Macro & GUI
skimage napari
Many objects
- Open xy_8bit_binary__many_vesicles.tif
- Create a label mask image (beware the output data type, because there are quite many objects)
- Count the number of objects in the label mask image
Show activity for:
ImageJ MorpholibJ Macro & GUI
skimage napari
Assessment
Fill in the blanks
Fill in the blanks, using these words: less, larger, 6, 255, 4, more.
- In 3D, pixels have _____ neighbors than in 2D.
- 8-connected connectivity results in _____ objects than 4-connected connectivity.
- In 3D, pixels have __ non-diagonal neighbors.
- In 2D, pixels have __ non-diagonal neighbors.
- A 8-bit label mask image can have maximally _____ objects.
- The maximum value in a label mask image is equal to or _____ than the number of objects.
Solution
- more
- less
- 6
- 4
- 255
- larger
Follow-up material
Recommended follow-up modules:
Learn more: