Skip to main content

bayer/demosaic/
mod.rs

1//! Collection of demosaicing algorithms.
2
3use ::{BayerDepth,RasterDepth};
4
5/// The demosaicing algorithm to use to fill in the missing data.
6#[derive(Clone,Copy,Debug,Eq,PartialEq)]
7pub enum Demosaic {
8    None,
9    NearestNeighbour,
10    Linear,
11    Cubic,
12}
13
14macro_rules! rotate {
15    ($v0:ident <- $v1:ident) => {{
16        let rot = $v0;
17        $v0 = $v1;
18        $v1 = rot;
19    }};
20    ($v0:ident <- $v1:ident <- $v2:ident) => {{
21        let rot = $v0;
22        $v0 = $v1;
23        $v1 = $v2;
24        $v2 = rot;
25    }};
26    ($v0:ident <- $v1:ident <- $v2:ident <- $v3:ident <- $v4:ident <- $v5:ident <- $v6:ident) => {{
27        let rot = $v0;
28        $v0 = $v1;
29        $v1 = $v2;
30        $v2 = $v3;
31        $v3 = $v4;
32        $v4 = $v5;
33        $v5 = $v6;
34        $v6 = rot;
35    }};
36}
37
38pub mod cubic;
39pub mod linear;
40pub mod nearestneighbour;
41pub mod none;
42
43/// Check if the image depth and the raster depth are compatible.
44fn check_depth(bayer: BayerDepth, raster: RasterDepth) -> bool {
45    match raster {
46        RasterDepth::Depth8 =>
47            bayer == BayerDepth::Depth8,
48        RasterDepth::Depth16 =>
49            bayer == BayerDepth::Depth16BE || bayer == BayerDepth::Depth16LE,
50    }
51}