Expand description
tpt-cv-core — zero-copy image buffers, color spaces, and pixel math.
This crate is no_std capable: the core math has zero alloc dependency in
the no_std path. Allocating types (owned images, vectors) require the
alloc or std features.
§Example
use tpt_cv_core::image::{Image, ImageBuf};
use tpt_cv_core::pixel::Pixel;
use tpt_cv_core::ops;
// Borrow a byte slice as a 2×1 RGB image (zero-copy).
let img = Image::<_, 3>::new(&[10u8, 20, 30, 40, 50, 60], 2, 1).unwrap();
assert_eq!(img.pixel(1, 0).channels, [40, 50, 60]);
// Owned image + saturating arithmetic into a caller-provided destination.
let a = ImageBuf::<u8, 1>::with_value(2, 1, 250);
let b = ImageBuf::<u8, 1>::with_value(2, 1, 10);
let mut dst = ImageBuf::<u8, 1>::new(2, 1);
assert!(ops::add_sat(&a.as_image(), &b.as_image(), &mut dst.as_image_mut()));
assert_eq!(dst.as_image().pixel(0, 0).scalar(), 255); // saturating, not 260Modules§
- color
- Color space representations and conversions.
- image
- Zero-copy image buffers over borrowed slices, with row-pitch (stride) support for sub-image views and a caller-provided destination buffer convention so pipelines never allocate per frame.
- ops
- Pixel-wise arithmetic: add, sub, mul, blend, and clamp, with saturating
and wrapping variants. Operations write into a caller-provided destination
and return
falseon size mismatch. - pixel
- Multi-channel pixel types and the
Sampletrait.