What is RoI Align and why is it important?
RoI Align (Region of Interest Align) extracts a fixed-size feature map from a proposed image region without rounding its boundaries to integer feature-map positions. Introduced in Mask R-CNN, it uses bilinear interpolation to preserve spatial alignment—particularly important for predicting accurate instance-segmentation masks.
Why was RoI Align needed?
- RoI Pooling divides a proposal into bins but rounds the region boundaries and bin coordinates to the feature grid. That quantization can shift which features correspond to object edges.
- RoI Align retains fractional coordinates and samples feature values at precise positions using bilinear interpolation, then aggregates samples within each bin.
- The result is a fixed output size (for example,
7×7or14×14) while reducing misalignment between object locations and extracted features.
How does bilinear interpolation work?
Suppose four neighboring feature-map samples have values:
- Top-left:
10; top-right:20. - Bottom-left:
30; bottom-right:40.
We want the value at a sample point 25% across from the left and 50% down from the top (x=0.25, y=0.50, measured within these four neighbors).
- Interpolate across the top:
10×0.75 + 20×0.25 = 12.5. - Interpolate across the bottom:
30×0.75 + 40×0.25 = 32.5. - Interpolate vertically:
12.5×0.50 + 32.5×0.50 = 22.5.
So RoI Align can sample the continuous position and obtain `22.5`, instead of snapping it to a nearby integer grid coordinate and reading only one neighboring value.
How is RoI Align used?
- Take a proposed rectangle expressed in image coordinates and map it to the backbone feature-map coordinate system.
- Subdivide the rectangle into a fixed number of spatial bins, without quantizing the region or bin boundaries.
- Sample points in every bin; use bilinear interpolation from the four neighboring feature samples.
- Aggregate the sampled values in each bin (for example, average or max). The resulting fixed-size tensor feeds classification, box, or mask heads.
For example, if there are 10 proposals, the backbone has 256 feature channels, and RoI Align outputs `7×7` bins, its feature tensor has shape `(10, 256, 7, 7)`, regardless of the different proposal sizes.
Why is spatial alignment important?
- A small rounding shift can move predicted edges away from actual object boundaries.
- Bounding-box classification can tolerate some spatial shift, but instance segmentation needs much closer pixel-to-pixel correspondence.
- Mask R-CNN showed that avoiding coordinate quantization substantially improves mask prediction.
Important: RoI Align does not itself propose or classify objects. It extracts aligned features for regions supplied to it. Proposal generation is covered by the previous RPN question.
Key takeaway: RoI Pooling rounds region coordinates; RoI Align keeps fractional positions and interpolates features. Preserving this alignment improves precise localization and mask quality.
Research: Mask R-CNN — He et al. (ICCV 2017). Implementation: Torchvision roi_align.
Sources & Research References
Learning Sequence
Deep Learning Curriculum
What is non-maximum suppression (NMS) in object detection?
Explore Related Questions
Deepen your understanding across related Deep Learning topics.