6 个版本
使用旧的 Rust 2015
0.1.5 | 2017年7月22日 |
---|---|
0.1.4 | 2017年4月29日 |
0.1.3 | 2017年2月17日 |
在图像中排名第 590
每月下载量 8,265
在 3 个 crate 中使用 (2 个直接使用)
70KB
1.5K SLoC
LibBayer

关于
LibBayer 提供去马赛克拜耳(原始)图像的例程。
该库支持 8 位和 16 位图像。
提供几种去马赛克算法。查看 src/demosaic 目录以获取列表和它们的详细描述。通过复制或镜像邻近区域的数据来保留图像边界的像素。
LibBayer 完全使用 Rust 编写。提供底层算法的 C 绑定。
示例
在 examples/
目录中提供了一个示例程序
- showbayer - 一个简单的拜耳文件查看器。
- writebayer - 将图像转换为原始拜耳图像文件。
要克隆此存储库,运行
git clone https://github.com/wangds/libbayer.git
然后使用 Cargo 构建库并运行示例程序。
cargo build --release --example showbayer
要显示拜耳文件,运行
cargo run --release --example showbayer <width> <height> <depth> <example.raw>
在示例程序内部更改颜色滤波阵列(CFA)模式和去马赛克算法。
基本用法
将 LibBayer 添加到项目的 Cargo.toml 中的依赖项
[dependencies]
bayer = "0.1"
在项目中导入库,例如
extern crate bayer;
从磁盘打开拜耳文件。
let mut file = File::open(Path::new("example.raw")).unwrap();
此原始数据只包含每个像素的红、绿或蓝色值。没有其他头部数据,因此图像宽度、高度、像素深度和 CFA 模式必须从其他地方提供。
分配将解码图像的缓冲区。
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);
然后运行去马赛克过程
let cfa = bayer::CFA::RGGB;
let alg = bayer::Demosaic::Linear;
bayer::run_demosaic(&mut file, bayer::BayerDepth:Depth8, cfa, alg, &mut dst);
请注意,许多相机将捕获每个像素(通道)12 位,但以每个像素 16 位存储数据。这些应被视为此库的每个像素 16 位。
文档
- 文档.
作者
David Wang
依赖项
~1.5MB
~30K SLoC