Image mask (source code)

= Image mask

An image mask is a <function> on image coordinates specifying which pixels or regions are retained or weighted. A binary mask $m(x)\in\{0,1\}$ selects a region, while a soft mask takes intermediate weights. Applying the mask pointwise gives $I_m(x)=m(x)I(x)$ for image intensity $I$.

For example, a mask equal to one inside a disk and zero outside retains only that disk of an image. An edge with fractional weights can smooth the transition. The mask describes location or weighting, rather than assigning a new color to every retained pixel.

In <Fourier analysis>, multiplication by a <window function> in the image plane corresponds to <convolution> in frequency, with the constant depending on the Fourier convention. A sharp binary boundary can therefore introduce broad high-frequency contributions. This explains why cropping and spectral filtering have different mathematical effects.