Did you know? Identifying a dog in a photo is one task. Finding exactly which pixels belong to the dog is a different task. A computer-vision model that colours the dog’s silhouette while leaving the background untouched is performing image segmentation.
Quick answer: read image pixels → calculate visual features → estimate a category or object label for image regions → create a pixel-level mask → compare it with verified labels. Some systems outline every pixel of a category; others separate individual objects even when they belong to the same category.
Think of a colouring book. A classifier might say, “This picture contains two bicycles.” A segmentation system tries to supply the outlines that tell you precisely where to colour them. This difference is useful in photo editing, satellite imagery, manufacturing inspection and more.
Three kinds of image segmentation to know
- Semantic segmentation: label pixels by category—for example, road, sky, tree or person.
- Instance segmentation: identify separate objects, such as Bicycle 1 and Bicycle 2, and estimate each object’s mask.
- Panoptic segmentation: combine category-level scene labelling with distinctions between individual countable objects.
Those terms are not interchangeable. If two dogs stand side by side, semantic segmentation may colour both as “dog.” Instance segmentation tries to mark them as two separate objects. Panoptic systems aim to represent both the individual dogs and categories such as sky or pavement in one scene.
Step 1: Turn a photograph into numerical information
An image is made of pixels, often represented with red, green and blue numerical values. A model may resize or normalise these numbers before processing them. Its available detail depends on the input resolution and the preprocessing choices.
Imagine a small red apple sitting on a red table. Because both surfaces have similar colours, separating apple from background may require shape, texture, contextual information and training examples, not merely finding red pixels.
A silhouette cannot be more precise than the evidence available. If the image is blurry or too small, the boundary may be uncertain even though the general category is obvious.
Step 2: Find local patterns and context
Vision models learn features that respond to patterns across the image. Convolutional networks can use locally shared filters; other architectures use attention and different learned representations.
Early processing may reflect edges, textures and colour contrasts. Later representations can combine wider context. A model may infer that a curved outline and leaf-like texture belong to one plant even if the background has a similar shade.
These learned patterns are not always human-readable rules. A segmentation model may succeed on one kind of scene and fail on unfamiliar lighting, camera angles or objects.
Step 3: Produce a mask rather than one label
A segmentation mask associates image positions with predicted categories or objects. In a simple binary mask, a pixel can be marked as belonging to the target object or not. Other models produce a score for several categories at each pixel.
The output may be stored as a grid of labels aligned to the original image. If the mask is generated at a lower resolution, software may resize it to match the image, but that interpolation does not create missing detail.
Some models also return confidence scores. A neat boundary is still only a prediction: a score does not prove that every pixel was assigned correctly.
Key distinction: An object detector says roughly where an item is, often using a rectangle. Segmentation tries to estimate which pixels form the item or region.
Step 4: Understand boxes versus masks
Imagine a photo of a person holding an umbrella. A detection model might draw a rectangular box around the umbrella. That box will also include some sky or other background.
A segmentation model can estimate an irregular shape following the umbrella’s canopy and handle. A good mask may therefore support selective editing or measuring visible area more accurately than a coarse rectangle.
But segmentation is not always necessary. If an app only needs to count the number of objects in a photograph, a suitable detector may be faster or simpler.
Step 5: Separate two objects of the same class
Suppose two bicycles overlap in a parking area. Their wheels and frames can touch or partially hide each other. Semantic labelling alone could place all bicycle pixels into one continuous category region.
Instance segmentation adds the challenge of assigning pixels to distinct object instances. Models can combine object proposals, class predictions and mask heads, or use other architectures.
Overlapping objects are difficult because some boundaries are invisible. A model estimates what is supported by its learned patterns, rather than revealing information that the photograph never captured.
Step 6: Describe a whole scene
A street photograph may contain countable things such as cars and people alongside broad materials such as sky, pavement and road. Panoptic segmentation aims for a coherent pixel-level interpretation that also separates individual countable objects.
That is useful when an application needs both kinds of information. For example, mapping a scene for research may require where the road appears and where separate vehicles appear.
A panoptic label is still not a verified understanding of the complete scene. It does not prove which car belongs to which person or why someone is standing in a particular spot.
Step 7: Train using appropriately verified masks
In supervised segmentation, a model can learn from photographs paired with annotated target masks. A human annotator or another checked procedure marks which pixels belong to each defined class or object.
Annotation quality matters. Two people can disagree about a blurry leaf boundary or transparent object. Developers need definitions for ambiguous edges and a method for reviewing inconsistent examples.
If the training set contains only daytime street images, performance on night-time rain may be unreliable. Representative lighting, scenes and camera types are essential for generalisation.
Step 8: Measure overlap using intersection over union
A standard way to evaluate a predicted mask is intersection over union (IoU). Count pixels included in both the predicted region and the reference region, then divide by the total number appearing in either.
Here is a fictional classroom calculation. Imagine the predicted and reference masks overlap in six pixels. Their combined union contains eight distinct pixels. IoU is 6 ÷ 8 = 0.75.
An IoU of 0.75 means 75% overlap relative to the union in this toy example. It does not mean that the model is 75% sure, that all classes perform equally, or that every boundary error is harmless.
Developers may report class-wise IoU, mean IoU or other metrics depending on the task. A high score on broad background regions can conceal mistakes on small but important objects.
Step 9: Evaluate on unfamiliar scenes
Test the model on images not used to create or tune its masks. Include relevant conditions: odd viewpoints, partial occlusion, changes in scale, different textures and backgrounds.
For a manufacturing inspection tool, missing a tiny defect may be more consequential than slightly mislabelling an unimportant surface. For a school photography tool, a small imperfect edge may be acceptable.
The right performance target depends on the user, cost of errors and the purpose. An impressive demo on three hand-picked images is not enough evidence for deployment.
Where segmentation can help
- Photo editing: select an object or separate foreground from background.
- Satellite research: estimate visible land-cover categories and investigate changes between dates.
- Manufacturing: locate candidate surface areas that need inspection.
- Autonomous-systems research: map visible roads and obstacles as one part of a larger sensing workflow.
- Scientific imagery: support measurements after experts verify that the labels are appropriate.
In sensitive settings, a segmentation output should support appropriately qualified review, not automatically substitute for it. A coloured image is not a diagnosis, a property boundary or proof of an event.
How does segmentation relate to the other vision tools?
An image classifier answers which broad label may apply to an image. Object detection estimates the locations of selected items. Segmentation describes their spatial regions. Text recognition works with written marks and characters.
These methods can work together but address distinct questions. An application might first detect a document, then segment a region and finally use OCR to read printed text.
See How AI Recognises Objects in Photos and How AI Reads Handwriting and Printed Text to compare their roles.
Try it: make a segmentation mask on graph paper
Draw an eight-by-eight grid. Shade a simple L-shaped object using ten squares. On a second transparent or copied grid, draw an estimated mask that misses two squares and includes one extra background square.
Count the overlap and union. Because eight object squares overlap and one extra predicted square appears, the union contains eleven: IoU is 8 ÷ 11 ≈ 0.73.
This deliberately simple exercise shows why a box around the L-shape is different from the L-shaped mask itself, and why IoU measures the intersection relative to the union.
Five mistakes worth avoiding
- “A box is the same as a pixel mask.” A box includes background around irregular shapes.
- “Semantic masks separate each individual object.” Instances are a different output requirement.
- “A high average score covers every tiny object.” Rare classes and small boundaries need separate tests.
- “A sharp outline proves the underlying category.” An attractive mask can still label the wrong thing.
- “All image pixels are equally certain.” Occlusion, blur and annotation differences matter.
Frequently asked questions
What is semantic segmentation in AI?
It assigns category labels to image pixels, such as tree, road or sky, without necessarily distinguishing separate objects within the same category.
What is instance segmentation?
It predicts separate object instances and estimates a mask for each one, such as two distinct bicycles.
Does segmentation recognise handwriting?
It can help isolate regions, but recognising characters is a separate OCR task.
What is IoU?
Intersection over union compares the overlapping pixels of two regions with all pixels covered by either region.
Can a segmentation model determine who someone is?
No. Outlining a visible person does not establish their identity.
Your one-minute takeaway
- Segmentation predicts pixel-level regions rather than only image labels or rectangular boxes.
- Semantic, instance and panoptic segmentation answer different spatial questions.
- Use verified masks, appropriate evaluation and human review when boundaries matter.
Trusted sources and related AI explainers
- TensorFlow: Image Segmentation Tutorial — an official pixel-label training example.
- Torchvision: Segmentation Models and Evaluation — semantic models, pretrained categories and IoU.
- How Convolutional Neural Networks Read Images — the learned visual features.
- How AI Recognises Objects in Photos — classification and detection.
- How AI Reads Satellite Images to Detect Changes — a spatial-mapping application.
- How AI Is Tested Before Release — why a mask needs independent verification.
- How AI Works: Complete Overview — the wider series.