= Grayscale
{wiki}
= Greyscale
{synonym}
A <grayscale> image varies along shades from black to white rather than recording independent colour differences. A numerical <grayscale> image assigns one shade sample to each <pixel>; an encoding determines how that sample maps to a displayed shade. A colour <raster image> can also look <grayscale>, for example when its three <sRGB> components are equal.
\Image[/raster-pixels-grayscale-quantization.png]
{title=Toy quantization and sRGB encoding: more codes and more light are different questions}
The convention in our <lossy block averaging> example is black at the <integer> code 0 and white at 255. Its <arithmetic means> act on those stored codes. This is a fully specified numerical experiment, but it does not claim that code 128 means half the physical light of code 255. <PNG> explicitly allows samples that are not proportional to light: its <grayscale> interpretation depends on the indicated transfer curve, and can be device-dependent when that information is absent.https://www.w3.org/TR/png-3/#6Colour-values[W3C, PNG Specification, Third Edition, section 6.1: colour types, grayscale interpretation and transfer curves]{ref}
Two different questions therefore need different operations. To average \i[stored codes], average the <integers>. To average <relative luminance> for neutral <sRGB> shades, decode the codes to linear light, average there, and encode the result again. Equal weights on black and white give encoded value $1/2$ by the first method, but approximately $0.73536$ by the second. Rounded to eight-<bit> codes these are 128 and 188. This example concerns ideal neutral shades and the specified <sRGB> conversion; it does not assert a universal grayscale conversion for every colour encoding.
The upper panels hold the spatial grid fixed and change <sample depth>: four levels produce broad constant bands, while 256 levels make smaller numerical steps. The lower panels hold the colour interpretation fixed and compare encoded <sRGB> values with <relative luminance>. All panels are calculated synthetic examples, not measured display data. <Grayscale> is useful when shade structure is the quantity of interest: a synthetic scalar <image signal> can be inspected without introducing separate colour components.
Back to article page