Inferensys

Glossary

Semantic Segmentation

A computer vision task that assigns a class label to every pixel in an image, enabling precise delineation of defect regions without distinguishing between individual instances of the same class.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
PIXEL-LEVEL CLASSIFICATION

What is Semantic Segmentation?

Semantic segmentation is a computer vision task that assigns a class label to every pixel in an image, enabling precise delineation of defect regions without distinguishing between individual instances of the same class.

Semantic segmentation performs dense prediction by classifying each pixel into a predefined category, such as 'scratch,' 'background,' or 'corrosion.' Unlike object detection, which draws bounding boxes, this technique produces a pixel-accurate mask that maps the exact spatial extent of a defect. Architectures like U-Net and DeepLab use encoder-decoder structures with skip connections to preserve fine-grained spatial details lost during downsampling.

In manufacturing quality inspection, semantic segmentation quantifies defect morphology—area, perimeter, and shape irregularity—by analyzing the resulting binary or multi-class mask. This pixel-level precision is critical for pass/fail decisions based on dimensional tolerances. The model is trained using a cross-entropy loss or Dice loss function, which measures the overlap between the predicted segmentation map and the pixel-accurate ground truth annotation.

PIXEL-LEVEL UNDERSTANDING

Key Characteristics of Semantic Segmentation

Semantic segmentation transforms raw images into dense, class-labeled maps where every pixel is assigned a category. Unlike bounding box detection, this technique provides exact boundary delineation, making it indispensable for measuring defect area, perimeter, and complex morphology in high-precision quality inspection.

01

Dense Per-Pixel Classification

Assigns a class label to every pixel in the input image without exception. This produces a complete segmentation map of identical resolution to the input, where each pixel value corresponds to a predefined class index. For manufacturing, this means a scratch defect is not just located but precisely outlined at the pixel level, enabling accurate area measurement. Architectures like U-Net and DeepLab are purpose-built for this task, using encoder-decoder structures to capture both global context and fine spatial details.

02

Class Uniformity vs. Instance Distinction

All pixels belonging to the same semantic class are assigned the identical label, regardless of whether they represent one object or multiple disconnected regions. Two separate scratches on a metal surface both receive the 'scratch' label with no differentiation between them. This distinguishes semantic segmentation from instance segmentation, which assigns unique identifiers to each individual object. For quality inspection, this property is ideal when the total defect area matters more than counting individual defect instances.

03

Encoder-Decoder Architecture

Modern semantic segmentation models employ a symmetric encoder-decoder structure. The encoder, typically a CNN or Vision Transformer, progressively downsamples the image to extract hierarchical features and capture broad contextual understanding. The decoder upsamples these features back to the original resolution, reconstructing spatial detail. Skip connections between corresponding encoder and decoder layers preserve fine-grained boundary information that would otherwise be lost during downsampling, ensuring crisp defect edges.

04

Multi-Scale Context Aggregation

Effective segmentation requires understanding both the fine texture of a defect and its relationship to the surrounding surface. Techniques like atrous spatial pyramid pooling (ASPP) and spatial pyramid pooling capture features at multiple receptive field sizes in parallel. This allows the model to simultaneously analyze a small pit defect at fine scale while recognizing that it sits within a larger machined surface region. Multi-scale processing is critical for handling defects that vary dramatically in size within the same production line.

05

Loss Functions for Class Imbalance

Defect pixels often represent less than 1% of total image area, creating severe class imbalance. Standard cross-entropy loss fails here, as the model can achieve high accuracy by simply predicting 'background' everywhere. Specialized loss functions address this: Dice loss optimizes the overlap coefficient between prediction and ground truth directly. Focal loss down-weights easy background examples and forces the model to focus on hard, misclassified defect pixels. Tversky loss provides tunable control over precision-recall tradeoffs.

06

Boundary Refinement with Conditional Random Fields

Raw segmentation outputs often produce coarse, blob-like boundaries that fail to capture fine defect contours. Conditional Random Fields (CRFs) serve as a post-processing step that refines label assignments by modeling pairwise pixel relationships based on color similarity and spatial proximity. This encourages pixels with similar appearance to share the same label while respecting strong intensity gradients at true boundaries. Though increasingly replaced by learned refinement modules in modern architectures, CRFs remain valuable for applications requiring sub-pixel boundary accuracy.

SEGMENTATION TASK COMPARISON

Semantic vs. Instance vs. Panoptic Segmentation

A comparison of the three primary pixel-level classification tasks in computer vision, detailing their outputs, use cases, and treatment of object instances.

FeatureSemantic SegmentationInstance SegmentationPanoptic Segmentation

Pixel Classification

Assigns a class label to every pixel

Assigns a class label to every pixel

Assigns a class label to every pixel

Instance Differentiation

Output Granularity

Single mask per class

Multiple masks per instance

Unified mask per pixel

Handles 'Stuff' Classes

Handles 'Things' Classes

Overlapping Object Handling

Merged into one region

Individual masks can overlap

Individual masks can overlap

Typical Architecture

U-Net, DeepLab

Mask R-CNN, YOLACT

Panoptic FPN, MaskFormer

Primary Manufacturing Use Case

Quantifying total defect area

Counting and sizing individual defects

Complete scene understanding for robotic bin-picking

SEMANTIC SEGMENTATION EXPLAINED

Frequently Asked Questions

Explore the most common technical questions about pixel-level classification for manufacturing quality inspection, from architectural choices to deployment optimization.

Semantic segmentation is a computer vision task that assigns a class label to every pixel in an image, creating a dense prediction map where all pixels belonging to the same object category share the same label. Crucially, it does not distinguish between individual instances of the same class—two overlapping defects of type 'scratch' would be segmented as a single contiguous region. In contrast, instance segmentation detects each distinct object and provides both a class label and a pixel-wise mask for every individual instance, differentiating between 'scratch_1' and 'scratch_2'. For manufacturing quality inspection, semantic segmentation is ideal when you need to measure the total area or extent of a defect class across a component, while instance segmentation is required when you need to count, track, or measure individual defects separately. Architecturally, semantic segmentation models like U-Net and DeepLab output a single-channel probability map per class, whereas instance segmentation frameworks like Mask R-CNN add a detection head to first localize objects before masking them.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.