blad-cfa 0.0.3

Colour filter array (Bayer) plane decorrelation
Documentation
  • Coverage
  • 41.18%
    7 out of 17 items documented0 out of 4 items with examples
  • Size
  • Source code size: 9.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 580.25 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • n0tbhargav/blad
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • n0tbhargav

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:

approach ratio
mosaic as one grayscale 0.613
four CFA sub-planes 0.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.