Graphics / Reference / Pixel coordinate convention
Pixel coordinate convention
Under the convention used here, integer coordinates identify pixel centres rather than pixel corners. Pixel (x,y) is therefore the unit square centred at real coordinate (x,y).
The convention used here places the centre of pixel (x,y) at real coordinate (x,y).
Therefore pixel (x,y) occupies the square:
horizontal range: x - 1/2 to x + 1/2
vertical range: y - 1/2 to y + 1/2
Pixel centres lie at integer coordinates. Pixel boundaries therefore lie at half-integer coordinates. Around a centre pixel (x,y), nearby vertical boundaries occur at x +/- 1/2 and x +/- 3/2, and nearby horizontal boundaries occur at y +/- 1/2 and y +/- 3/2.
This convention matters whenever coverage, distance to a pixel centre, or rounding is used to choose a raster pixel.
It is not universal. Some graphics systems use a convention in which real coordinate (x,y) refers to the bottom-left corner of a pixel instead. Pixel-selection reasoning must use the coordinate convention of the system being considered.
Read
- Read the chapter: Pixel coordinate convention