liveBook · Manning

Image segmentation

As explained in Deep Learning with R, Third Edition

Image segmentation is the task of assigning semantic labels to individual pixels or regions of an image.

Image segmentation partitions an image into areas and assigns a semantic label to each pixel, producing a segmentation mask. Unlike image classification, which labels an entire image, segmentation preserves precise spatial information; unlike object detection, it does not stop at bounding boxes. section 11.1 section 11.5

Figure 11.1 The three main computer vision tasks: classification, segmentation, and detection
figure

Compare classification, segmentation, and object detection by the kind of spatial information each prediction retains. section 11.1

A from-scratch model first compresses the image with strided Conv2D layers, then expands the feature map with Conv2DTranspose layers until the output matches the input dimensions. Strided convolutions retain location information better than 2 × 2 max pooling, whose single value loses the winning location within each window. section 11.3.2 section 11.5

Training and inspecting a segmentation model

A practical R/Keras workflow normalizes images, predicts three per-pixel classes with a softmax output, compiles with Adam and sparse categorical cross-entropy, tracks foreground IoU, saves the best checkpoint, and compares a predicted mask with its target mask. A pretrained Segment Anything model provides an alternative and accepts point or box prompts. section 11.3.2 section 11.5

Segmentation provides more information than detection but costs more computation and requires more expensive pixel-precise annotations. Use detection instead when boxes are sufficient, such as counting objects without needing their exact shapes. section 12.0

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains masks, encoder-decoder architecture, spatial downsampling, training, metrics, checkpointing, and visualization.
Examples
Uses custom-background video calls, an R/Keras three-class model, predicted and target masks, and Segment Anything prompts.
What it assumes
Assumes introductory deep learning and computer vision context while positioning segmentation alongside classification and detection.
What you can do after
Build it from scratch with strided Conv2D and Conv2DTranspose layers, or apply Segment Anything with point and box prompts.
How it connects
Connects image classification, object detection, convolutional neural networks, semantic masks, and pretrained models.

Also explained in

Compare how 6 books explain image segmentation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.