A Bounding Box Around Selected Pixels

A bounding box stores row and column extremes covering all selected pixels. Its endpoint convention determines how to crop it.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace two selected points
  2. Handle the empty mask

Trace two selected points

Points at \((1,2)\) and \((3,5)\) give row bounds 1 through 3 and column bounds 2 through 5 inclusive. A half-open crop uses ends four and six. See cropping bounds.

Handle the empty mask

With no selected pixel, there are no extrema for this operation. Return a documented absent box. Running minima illustrate why manufacturing an initial extreme is unreliable.[1][2]

References

  1. scikit-image Contributors, NumPy Images and Coordinate Conventions ↩
  2. scikit-image Contributors, Image Data Types and Representable Values ↩