Raster graphics (source code)

= Raster graphics
{wiki}

= Raster image
{synonym}

<Raster graphics> describe a picture by an <array> of <pixels> on a grid. For a rectangular image of width $W$ and height $H$, write its stored values as $p_{rc}$, with $0\leq r<H$ and $0\leq c<W$. A <grayscale> <pixel> can have one shade value; a colour <pixel> can have several component values. The grid specifies where values belong, while the encoding specifies what those values mean. A <raster image> therefore needs dimensions and an interpretation of its samples, not just a string of numbers.

The appealing feature is that pictures become explicit data: selecting a rectangle selects entries of an <array>; comparing two images compares their <pixel> values; <image compression> can exploit repeated or related values. <Raster sampling and reconstruction> explains why the stored grid and the displayed picture are different objects. A square drawn around a sample is one display convention, not a claim that the original scene consisted of little squares.

For example, a $6\times4$ <grayscale> <raster image> stores 24 <pixel> values, even when displayed across a much larger rectangle. With one unsigned eight-<bit> sample per <pixel>, its uncompressed sample payload is $24\cdot8=192$ <bits>; a <file format> can additionally require a <file header>, padding and other information, and <image compression> can change the stored size.

Enlarging that image can copy each <pixel> into a block through <nearest-neighbor interpolation>, or infer intermediate values through <interpolation>. Either procedure supplies a reconstruction rule; neither determines which unrecorded detail was present in the original. <Vector graphics> use a different representation, specifying geometric objects to be rendered onto a chosen grid. Re-rendering such a description and enlarging an existing <raster image> are different operations.