How AVIF Encodes and Stores Monochrome Images
This article provides an overview of how monochrome and grayscale imagery is processed, encoded, and packaged within the AV1 Image File Format (AVIF). It covers the native single-channel encoding mechanisms of the underlying AV1 video codec, how color profiles and pixel layouts are structured, and the way the ISO Base Media File Format (ISOBMFF) container encapsulates this data alongside optional auxiliary channels such as alpha transparency.
Native AV1 Monochrome Encoding
Unlike older image formats that simulate grayscale by duplicating identical data across red, green, and blue channels—or populating neutral chroma planes in YUV color spaces—AVIF leverages native monochrome encoding defined in the AV1 video standard.
Within the AV1 bitstream, the sequence header contains a dedicated
syntax element named mono_chrome. When this flag is set to
1:
- The chroma components (\(U\) and \(V\)) are completely omitted from the bitstream.
- Only the luma channel (\(Y\)) is encoded and parsed.
- The format functions as a true 4:0:0 subsampled image.
This approach removes all metadata, transform blocks, and residual data associated with color planes, resulting in significant bandwidth and storage savings compared to encoding grayscale content in 4:2:0 or 4:4:4 profiles.
Bit Depth Support
The AV1 monochrome mode directly supports multiple bit depths without requiring format conversion:
- 8-bit: Standard dynamic range grayscale.
- 10-bit and 12-bit: High dynamic range and high-precision grayscale, which prevents banding artifacts in fine gradients (common in medical imaging, astrophotography, and print preparation).
The high_bitdepth and twelve_bit flags in
the sequence header determine the exact bit depth used for the single
encoded luma channel.
Container-Level Storage in ISOBMFF
An AVIF file encapsulates the AV1 bitstream within an ISOBMFF-compliant box structure. For monochrome files, container-level metadata specifically indicates that only a single image channel is present:
- Pixel Information Box (
pixi): This box defines the number of channels and their respective bit depths. For a standard monochrome image, thepixibox declaresnum_channels = 1, followed by the bit depth of that single channel. - Color Information Box (
colr): AVIF includes an NCLX (Color Configuration) box or an embedded ICC profile to ensure accurate display rendering. For monochrome images using NCLX, thematrix_coefficientsparameter is typically set to0(Identity) or1(Unspecified/Identity), preventing unnecessary color-space transformation matrices from executing on decode. - Primary Item Box (
pitm): Points directly to the single-plane AV1 image item stored within the media data box (mdat).
Handling Transparency in Monochrome AVIF
When a grayscale image requires transparency, AVIF does not re-enable chroma planes to carry alpha. Instead, it maintains storage efficiency by using an auxiliary image item:
- Base Image: Encoded as a pure monochrome AV1 bitstream (representing the grayscale luminance).
- Auxiliary Image: Encoded as a secondary, separate monochrome AV1 bitstream containing the alpha matte.
- Item Reference Box (
iref): Links the auxiliary image to the base image with the reference typeauxl(auxiliary list). Theaux_typeproperty specifies that the secondary plane acts as an alpha channel (urn:mpeg:mpegB:cicp:systems:auxiliary:alpha).
This architecture allows the image luminance and the transparency mask to be compressed independently using parameters optimal for each channel's content.