Sub topic 6
Panoptic Segmentation: a Unified Output
This chapter assumes you know basic Python and NumPy, semantic and instance segmentation, and object detection outputs such as boxes and confidence scores.
Panoptic segmentation assigns a class label to every pixel and separates individual objects when that separation makes sense. It combines semantic segmentation and instance segmentation in one prediction.
For example, an image may contain three cars, a road, and a sky. The road and sky are continuous regions called stuff. Each car is a separate object called a thing. A panoptic result identifies the road and sky by class, while giving each car its own instance identity.
Two maps in one result
A useful representation has two aligned maps:
- A class map stores the category at each pixel.
- An instance map stores an instance ID for thing pixels. Stuff pixels usually have ID
0.
The pair (class_map[y, x], instance_map[y, x]) describes pixel (y, x). Two pixels with the same thing class but different instance IDs belong to different objects.
| Region | Class map | Instance map |
|---|---|---|
| Road | road | 0 |
| First car | car | 1 |
| Second car | car | 2 |
| Sky | sky | 0 |
The instance ID is meaningful only within one image. ID 1 in another image does not refer to the same physical object.
Things, stuff, and void pixels
A thing class represents countable objects, such as person, car, or bicycle. A stuff class represents amorphous regions, such as grass, wall, or water. Thing pixels need instance IDs. Stuff pixels do not.
A panoptic output must be non-overlapping: each pixel belongs to at most one segment. This differs from raw instance masks, which can overlap before post-processing.
Some pixels cannot be assigned reliably. A system may label them as void, often using class ID -1 or a reserved dataset value. Void pixels are excluded from some evaluation calculations. Do not silently treat void as background, because that can distort both training and metrics.
>callout note Panoptic segmentation is a partition of the image. Check that every valid pixel has one class and that thing segments have distinct IDs. </callout note>
A simple merging rule
One practical pipeline predicts a semantic map for all pixels and instance masks for thing objects. Sort detected instances by confidence, then let higher-confidence masks claim pixels first. Reject low-confidence detections or masks with excessive overlap. Unclaimed stuff pixels keep their semantic labels. Unclaimed thing pixels may become void.
This rule is simple, but the ordering affects the result. A large, weak detection should not overwrite a smaller, high-confidence object. Real systems may use mask quality, category consistency, and overlap thresholds in addition to confidence.
Exercise
An image contains two cars and one road. What should the panoptic representation contain for the road and for each car?
Show answer
The road should have class “road” and instance ID 0. Both cars should have class “car,” but they should have different nonzero instance IDs.