+
Skip to content

virtualritz/libbayer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bayer

Version Status

Routines for demosaicing Bayer sensor (RAW) images.

Both 8-bit and 16-bit images are supported.

Several demosaicing algorithms are available. See the src/demosaic directory for a list and their individual descriptions. Pixels on the border of the image are retained by replicating or mirroring the data in the neighbourhood.

The crate is written entirely in Rust. C bindings to the underlying algorithms are provided.

Examples

  • showbayer – a simple Bayer file viewer.
  • writebayer – converts an image to a raw Bayer image file.

Run the examples programs using cargo.

cargo build --release --example showbayer

To display a Bayer file, run:

cargo run --release --example showbayer <width> <height> <depth> <example.raw>

Change the colour filter array (CFA) pattern and the demosaicing algorithm from inside the example program.

Basic Usage

Add bayer as a dependency to your project's Cargo.toml:

[dependencies]
bayer = "0.1"

Open a Bayer file from disk.

let mut file = File::open(Path::new("example.raw")).unwrap();

This raw data contains the red, green, or blue values at each pixel only. There is no additional header data, so the image width and height, pixel depth, and CFA pattern must be provided from elsewhere.

Allocate the buffer to which we will decode the image.

let img_w = 320;
let img_h = 200;
let depth = bayer::RasterDepth::Depth8;
let bytes_per_pixel = 3;
let mut buf = vec![0; bytes_per_pixel * img_w * img_h];

let mut dst = bayer::RasterMut::new(img_w, img_h, depth, &mut buf);

Then run the demosaicing process:

let cfa = bayer::CFA::RGGB;
let alg = bayer::Demosaic::Linear;

bayer::run_demosaic(&mut file, bayer::BayerDepth:Depth8, cfa, alg, &mut dst);

Note that many cameras will capture 12-bits per pixel (channel), but store the data as 16-bits per pixel. These should be treated as 16-bits per pixel for the purposes of this library.

Documentation

Author

David Wang

About

Bayer demosaicing algorithms, written in Rust.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 97.6%
  • C 2.4%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载