mod bayer;
mod border_mirror;
mod border_none;
mod border_replicate;
mod errcode;
#[macro_use]
mod none;
mod raster;
#[macro_use]
mod rotate;
mod cubic;
mod linear;
mod nearestneighbour;
pub use bayer::{BayerRead, ColorFilterArray};
pub use errcode::BayerError;
pub use errcode::BayerResult;
use crate::coretraits::Enlargeable;
use crate::ImageOwned;
use crate::ImageRef;
use crate::PixelStor;
#[allow(unused_imports)]
use crate::{DynamicImageOwned, DynamicImageRef, GenericImageOwned, GenericImageRef};
pub(crate) struct RasterMut<'a, T: PixelStor> {
x: usize,
y: usize,
w: usize,
h: usize,
stride: usize,
buf: &'a mut [T],
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DemosaicMethod {
None,
Nearest,
Linear,
Cubic,
}
pub(crate) fn run_demosaic_imagedata<T>(
r: &ImageRef<T>,
cfa: ColorFilterArray,
alg: DemosaicMethod,
dst: &mut RasterMut<'_, T>,
) -> BayerResult<()>
where
T: PixelStor + Enlargeable,
{
match alg {
DemosaicMethod::None => crate::demosaic::none::run_imagedata(r, cfa, dst),
DemosaicMethod::Nearest => crate::demosaic::nearestneighbour::run_imagedata(r, cfa, dst),
DemosaicMethod::Linear => crate::demosaic::linear::run_imagedata(r, cfa, dst),
DemosaicMethod::Cubic => crate::demosaic::cubic::run_imagedata(r, cfa, dst),
}
}
pub(crate) fn run_demosaic_imageowned<T>(
r: &ImageOwned<T>,
cfa: ColorFilterArray,
alg: DemosaicMethod,
dst: &mut RasterMut<'_, T>,
) -> BayerResult<()>
where
T: PixelStor + Enlargeable,
{
match alg {
DemosaicMethod::None => crate::demosaic::none::run_imageowned(r, cfa, dst),
DemosaicMethod::Nearest => crate::demosaic::nearestneighbour::run_imageowned(r, cfa, dst),
DemosaicMethod::Linear => crate::demosaic::linear::run_imageowned(r, cfa, dst),
DemosaicMethod::Cubic => crate::demosaic::cubic::run_imageowned(r, cfa, dst),
}
}
pub trait Debayer
where
Self: Sized,
{
type Output;
fn debayer(&self, alg: DemosaicMethod) -> Result<Self::Output, BayerError>;
}