Sub topic 1
What Image Segmentation Is and Why It Matters
Image segmentation assigns a meaning to individual pixels. Instead of predicting one label for an entire image, a segmentation model produces a spatial prediction that follows object boundaries and regions.
This chapter assumes you know basic Python and NumPy, convolutional neural networks, image classification, object-detection bounding boxes, confidence scores, and gradient-based loss functions.
Prerequisites
You should understand:
- An image as an array with height, width, and color channels.
- A class label as a category such as
car,road, ortree. - A bounding box as a rectangle around a detected object.
- A neural network prediction as a value that can be optimized with a loss function.
Three segmentation tasks
The three main tasks differ in what counts as a separate prediction.
Semantic segmentation
Semantic segmentation assigns one class to every pixel. All pixels belonging to the same class receive the same label, even when they belong to different objects.
For example, a street image might label pixels as road, building, car, or sky. Two cars can both be labeled car, but the output does not say which pixels belong to the first car or the second.
The output is usually a label map with shape (height, width). Each integer in the map refers to a class.
Instance segmentation
Instance segmentation separates individual objects. If an image contains three cars, the model produces three object masks, each with its own class, confidence score, and instance identity.
This output is useful when an application must count objects, measure each object, or track objects across video frames. Mask R-CNN is a common model family for this task. It first proposes and classifies objects, then predicts a pixel mask for each detected object.
Panoptic segmentation
Panoptic segmentation combines the previous two tasks. It labels every pixel with a semantic class and assigns a separate instance identity to countable objects.
A panoptic result distinguishes two types of classes:
- Things are countable objects, such as people, cars, and bottles.
- Stuff describes amorphous regions, such as sky, grass, road, and water.
A person must have an instance identity, while all connected or disconnected road pixels can share the road class without separate identities.
Why pixel-level predictions matter
Bounding boxes include background pixels and cannot describe object shape precisely. Segmentation masks support accurate area measurement, robotic interaction, medical-image analysis, autonomous driving, image editing, and quality inspection.
The task also creates practical trade-offs. Fine masks require detailed annotations and more computation than image classification. A model can obtain a high detection score while producing a poor boundary, so segmentation requires mask-specific evaluation.
> callout note > Choose the task from the required output. Use semantic segmentation for region understanding, instance segmentation for separate objects, and panoptic segmentation when both are needed.
Exercise
An image contains several cars and a continuous road region. Which task should you choose if you need each car separated while keeping the road as one class?
Show answer
Panoptic segmentation, because it gives separate identities to the cars and a shared semantic label to the road.