Computer Vision

Semantic vs Instance Segmentation

Distinguishing pixel-level semantic classification, individual object instance masks, and unified panoptic scene understanding.

🟡 intermediate5 min readvision
Image Segmentation assigns pixel-level class labels to an entire image. Semantic Segmentation classifies every pixel into a category (e.g. 'person', 'road', 'sky') without distinguishing separate object instances. Instance Segmentation identifies and masks distinct individual object instances (e.g. 'person #1', 'person #2'). Panoptic Segmentation unifies both, labeling stuff pixels (background road/sky) and thing pixels (countable individual objects) in a single output.

The Three Pillars of Image Segmentation

  INPUT IMAGE                  SEMANTIC SEGMENTATION           INSTANCE SEGMENTATION           PANOPTIC SEGMENTATION
  (Two people on a road)       (Class per pixel)               (Mask per individual object)   (Unified Stuff + Things)
  ┌──────────────────────┐     ┌──────────────────────┐        ┌──────────────────────┐        ┌──────────────────────┐
  │ [Person1] [Person2]  │     │ [Person]   [Person]  │        │ [Person1]  [Person2] │        │ [Person1]  [Person2] │
  │    (Road)  (Sky)     │     │    (Road)   (Sky)    │        │    (No Road) (No Sky)│        │    (Road)   (Sky)    │
  └──────────────────────┘     └──────────────────────┘        └──────────────────────┘        └──────────────────────┘
  All person pixels merged!    Individual masks!               Unified scene mask!
Segmentation TypeTarget FocusTreats Objects AsExample ClassesClassic Model
SemanticCategory per pixelAmorphous category blobsSky, Road, Grass, BuildingU-Net, DeepLabV3+
InstanceCountable objectsDistinct individual instancesPerson 1, Person 2, Car 1, Car 2Mask R-CNN, YOLACT
PanopticComplete sceneStuff + Things unifiedSky (Stuff) + Person 1 (Thing)Panoptic FPN, Mask2Former

1. Semantic Segmentation

Assigns a class label $c \in {1, \dots, C}$ to every single pixel $(x, y)$ in the image.

It does NOT differentiate between multiple instances of the same class. Three cars parked in a row are merged into a single contiguous "car" region.

2. Instance Segmentation (Mask R-CNN)

Detects and segments individual countable objects ("Things").

Mask R-CNN adds a small Fully Convolutional Network (FCN) branch to Faster R-CNN to predict a binary $m \times m$ pixel mask for each detected bounding box:

  RoI Align ──► [ Feature Crop ] ──┬──► [ Class Head ] ──► Label: "Person"
                                   ├──► [ Box Head ]   ──► Bounding Box [x, y, w, h]
                                   └──► [ Mask Head ]  ──► 28x28 Binary Mask

RoIAlign vs RoIPool

Standard RoIPool quantized region coordinates to integers, causing pixel misalignment.

RoIAlign uses bilinear interpolation to extract exact continuous spatial features without rounding errors, enabling precise pixel-level mask predictions.

3. Panoptic Segmentation

Combines the strengths of both worlds:

Panoptic segmentation outputs a non-overlapping pixel map where every pixel receives a pair $(C_i, I_i)$: Class Category $C_i$ and Instance ID $I_i$.

Say this out loud

Semantic segmentation labels every pixel by category without separating individual objects. Instance segmentation detects and masks distinct object instances (Person 1 vs Person 2). Panoptic segmentation unifies both into a single complete scene understanding map, combining background stuff categories (road, sky) with individual object things (cars, people).

Follow-ups to expect

Check yourself

Question 1 of 3

How does Instance Segmentation differ from Semantic Segmentation when two people stand next to each other in an image?

More in Computer Vision

See all →
Image Augmentation Strategies5 minResizing, Normalization & Colour Spaces4 minResNet, EfficientNet & Friends5 min