QM Coder

A simple QM coding implementation in Rust for image bit-plane compression.

Description

This project provides a command-line utility, qm-coder, which uses QM arithmetic coding to compress image files. It processes each bit-plane (from MSB to LSB) separately and reports the compression results for each plane. It also supports optional Gray code transformation.

Usage

To use the application, you first need to build it.

Building

cargo build --release

The executable will be located at target/release/qm-coder.

Encoding a file

To encode a file, provide the input and output file paths. You can optionally enable Gray code transformation using the --gray flag.

./target/release/qm-coder <input_file> <output_file> [--gray]

For example:

./target/release/qm-coder baboon.raw baboon.raw.gray.qm --gray

The utility will output a bit-plane compression report:

Applying Gray code transformation...
Sample (Original): [145, 55, 48, 89, 137]
Sample (Gray):     [217, 44, 40, 117, 205]

Bit-plane compression report:
Bit-plane 7: 208891 bits
Bit-plane 6: 120365 bits
Bit-plane 5: 228308 bits
Bit-plane 4: 251446 bits
Bit-plane 3: 268872 bits
Bit-plane 2: 270452 bits
Bit-plane 1: 270731 bits
Bit-plane 0: 271011 bits
Total compressed size: 236260 bytes
Description
No description provided
Readme MIT 3.1 MiB
Languages
Rust 100%