Finding shapes
Thresholding with Otsu's method and adaptive thresholds, morphology to clean masks, and connected components to count, measure and outline objects.
About 5 hours of study
Learning objectives
- Turn images into masks with chosen or automatic thresholds
- Clean masks with opening and closing
- Label objects and measure their properties
Lessons
- 1
Thresholding and Otsu's method Intermediate
Thresholding splits an image into foreground and background. Apply global and inverse thresholds, let Otsu's method choose the threshold from the histogram, and use adaptive thresholds when the lighting is uneven.
- 2
Morphology: erosion, dilation, opening and closing Intermediate
Clean up binary masks by growing and shrinking shapes. Apply erosion and dilation with a structuring element, combine them into opening and closing to remove specks and fill holes, and extend the idea to greyscale images with the top-hat transform.
- 3
Connected components and contours Intermediate
Turn a mask into separate objects. Label connected regions with flood fill, compare 4- and 8-connectivity, measure each object's area, bounding box and centroid, and find its boundary pixels, the idea behind contours.
Module practice
- Computer vision: Binary and inverse thresholdsEasy
- Computer vision: Otsu's thresholdMedium
- Computer vision: Adaptive threshold for uneven lightHard
- Computer vision: Erode or dilate a binary imageEasy
- Computer vision: Opening and closingMedium
- Computer vision: Greyscale opening and top-hatHard
- Computer vision: Count the objectsEasy
- Computer vision: Label regions and measure themMedium
- Computer vision: Filter objects, trace boundariesHard