= Binary image
A <binary image> assigns one of two values to every <pixel>, commonly $0$ and $1$ or false and true. It can represent a selected region, such as marks separated from a page background, without retaining all the original brightness values. The two values express a chosen classification of <pixels>, not necessarily two physical colors in the original scene.
For example, define <image thresholding> by selecting intensities at least $100$:
$$
I=\begin{pmatrix}80&120\\150&90\end{pmatrix},
\qquad
B_{ij}=\begin{cases}1&I_{ij}\geq100,\\0&I_{ij}<100,\end{cases}
\qquad
B=\begin{pmatrix}0&1\\1&0\end{pmatrix}.
$$
The output preserves which side of the threshold each value occupied but loses the distinction between $120$ and $150$. Changing the threshold changes the selected region, so interpreting the result requires the selection rule as well as the image.
A <binary image> is useful as input to <connected-component labeling>. There, <pixel connectivity> determines whether diagonally touching selected <pixels> belong to the same region. SciPy's labeling operation accepts zero as background and all nonzero values as foreground; an input with several nonzero intensities is consequently treated as a foreground mask by that particular API.<label in the SciPy documentation>[Parameters, input: zero background and nonzero foreground]{ref}
Two possibilities require one <bit> of information per <pixel> in a direct packed representation. An actual array or image file can use more storage, or compression can exploit repeated patterns. Also distinguish a <binary image> from a label image containing several region identifiers: a label value of three need not mean brighter foreground than a label value of one.
Back to article page