hcomp#
CCSDS 123.0-B Lossless Multispectral and Hyperspectral Image Compression in pure OCaml.
Overview#
Predictor-based lossless compression for multi-band (hyperspectral) images following the CCSDS 123.0-B standard, used for space science data systems. The algorithm uses a local difference predictor with spatial and spectral neighbors followed by an adaptive entropy coder.
Features#
- Local difference predictor using spatial and spectral neighbors
- Adaptive entropy coder (Rice-like variable-length coding)
- Band-interleaved-by-pixel (BIP) sample ordering
- Support for 1--16 bits per sample
Installation#
Install with opam:
$ opam install hcomp
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install hcomp
Usage#
(* Compress + decompress 256x256 4-band 12-bit imagery. *)
let image_data = Bytes.make (4 * 256 * 256 * 2) '\x00'
let compressed =
Hcomp.compress ~bands:4 ~width:256 ~height:256 ~bits_per_sample:12 image_data
let restored =
Hcomp.decompress ~bands:4 ~width:256 ~height:256 ~bits_per_sample:12
compressed
let () = assert (Bytes.equal restored image_data)
Licence#
ISC License. See LICENSE.md for details.