Cropping with Half-Open Bounds

A rectangular crop selects a range of rows and a range of columns under a coordinate convention.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace a three-by-two crop
  2. Translate positions into the crop

Trace a three-by-two crop

Rows from 1 through before 3 and columns from 2 through before 5 give two rows and three columns. Half-open slices give the size from endpoint differences.

Translate positions into the crop

The global pixel at row 1 and column 2 becomes row zero and column zero in the crop. An operation preserving original positions must keep both starting offsets. See image coordinate roles.[1][2]

References

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