= Sample depth
{title2=$b,\quad 2^b$}
The <sample depth> $b$ is the number of <bits> allocated to one stored sample. An unsigned $b$-<bit> <integer> has $2^b$ codes, $0,\ldots,2^b-1$. This is per component, not automatically per <pixel>: three eight-<bit> components require 24 payload <bits> per <pixel>. A <raster image> with $W H$ <pixels> and $k$ such components requires $WHkb$ payload <bits> before <data compression>, padding or a <file header>.
For a toy normalized shade $x\in[0,1]$, define uniform <quantization (signal processing)> with endpoints included by
$$
q_b(x)=\left\lfloor(2^b-1)x+\frac12\right\rfloor,\qquad \widehat x_b=\frac{q_b(x)}{2^b-1}.
$$
The <floor function> implements rounding to the nearest code, with exact halves rounded upward. The reconstruction step is $\delta_b=1/(2^b-1)$, and $|\widehat x_b-x|\leq\delta_b/2$. For $b=2$, the levels are $0,1/3,2/3,1$; for $b=8$ they are $0,1/255,\ldots,1$. Increasing <sample depth> refines this value grid without changing the spatial grid. These levels are uniform in $x$; if $x$ is encoded <sRGB>, they are not uniform in <relative luminance>.
<PNG> uses a bit-depth field per sample or palette index. Its <grayscale> type without alpha permits 1, 2, 4, 8 or 16 <bits> per sample; its truecolour type permits 8 or 16 <bits> per component. These are format-specific restrictions, not a rule for every <raster image>.https://www.w3.org/TR/png-3/#11IHDR[W3C, PNG Specification, Third Edition, section 11.2.1, IHDR, Table 12]{ref}
Back to article page