Giter VIP home page Giter VIP logo

libbayer's Introduction

LibBayer Version Status

About

LibBayer provides routines for demosaicing Bayer (raw) images.

The library supports 8-bit and 16-bit images.

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.

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

Examples

An example program is provided in the examples/ directory:

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

To clone this repository, run:

git clone https://github.com/wangds/libbayer.git

Then build the library and run the example 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 LibBayer as a dependency to your project's Cargo.toml:

[dependencies]
bayer = "0.1"

Import the library in your project, e.g.:

extern crate bayer;

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

libbayer's People

Contributors

wangds avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.