Skip to main content

Crate blad_cfa

Crate blad_cfa 

Source
Expand description

Colour filter array decorrelation.

A Bayer mosaic interleaves four colour channels on a 2×2 grid, so horizontally adjacent samples measure different colours. Predictive image coders assume neighbouring samples are correlated, and that assumption is violated on every step — which is why compressing a mosaic as if it were a grayscale image leaves a large amount on the table.

Splitting the mosaic into four half-resolution planes, one per CFA position, restores the assumption: within a plane, every neighbour measures the same colour.

Measured on a Hasselblad X1D 3FR (8384×6304, 16-bit, ISO 400), lossless JXL:

approachratio
mosaic as one grayscale0.613
four CFA sub-planes0.534

12.8% smaller, and faster — the planes are quarter-size and encode in parallel. General-purpose compressors cannot do this because they do not know the data is a mosaic.

§Why this operates on bytes

The transform is a pure reordering: samples are moved, never read. So it needs neither the CFA pattern (RGGB vs BGGR vs …) nor the byte order — which keeps it exactly reversible for any sensor, and avoids materialising the image as u16.

Structs§

Planes
Four half-resolution planes decomposed from a mosaic, as raw sample bytes in the source’s own byte order.

Enums§

Error

Constants§

PLANE_COUNT
The four CFA positions, in raster order: (0,0), (1,0), (0,1), (1,1).

Functions§

merge
Re-interleave four sub-planes back into a mosaic.
split
Split a mosaic into four sub-planes.

Type Aliases§

Result