pub struct ComputeKernel { /* private fields */ }Expand description
Collection of CPU compute kernels for image processing.
Every method is a pure function — &self is used only to read
KernelConfig; no mutable state is kept.
Implementations§
Source§impl ComputeKernel
impl ComputeKernel
Sourcepub fn new(config: KernelConfig) -> Self
pub fn new(config: KernelConfig) -> Self
Create a new ComputeKernel with the given configuration.
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create a new ComputeKernel with default configuration.
Sourcepub fn config(&self) -> &KernelConfig
pub fn config(&self) -> &KernelConfig
Return a reference to the current configuration.
Sourcepub fn rgba_to_yuv420(
&self,
rgba: &[u8],
width: u32,
height: u32,
) -> Option<Vec<u8>>
pub fn rgba_to_yuv420( &self, rgba: &[u8], width: u32, height: u32, ) -> Option<Vec<u8>>
Convert packed RGBA to planar YUV 420.
Layout of the returned buffer:
- Y plane :
width * heightbytes - Cb plane :
(width/2) * (height/2)bytes - Cr plane :
(width/2) * (height/2)bytes
rgba must have length width * height * 4.
Returns None if the input length is unexpected.
Sourcepub fn yuv420_to_rgba(
&self,
yuv: &[u8],
width: u32,
height: u32,
) -> Option<Vec<u8>>
pub fn yuv420_to_rgba( &self, yuv: &[u8], width: u32, height: u32, ) -> Option<Vec<u8>>
Convert planar YUV 420 to packed RGBA.
Expects the same memory layout as produced by rgba_to_yuv420.
Returns None if the input length is unexpected.
Sourcepub fn gaussian_blur(
&self,
pixels: &[f32],
width: u32,
height: u32,
sigma: f32,
) -> Option<Vec<f32>>
pub fn gaussian_blur( &self, pixels: &[f32], width: u32, height: u32, sigma: f32, ) -> Option<Vec<f32>>
Apply a separable Gaussian blur.
Kernel radius is ceil(3 * sigma). Each pixel channel is treated as
an independent f32 sample (grayscale or multi-channel flattened).
Returns None if the input length doesn’t match width * height.
Sourcepub fn sobel_edges(
&self,
gray: &[f32],
width: u32,
height: u32,
) -> Option<Vec<f32>>
pub fn sobel_edges( &self, gray: &[f32], width: u32, height: u32, ) -> Option<Vec<f32>>
Compute Sobel gradient magnitude for a grayscale image.
Input gray must have length width * height.
Returns None if length mismatch. Border pixels are set to 0.
Sourcepub fn histogram_equalization(
&self,
gray: &[u8],
width: u32,
height: u32,
) -> Option<Vec<u8>>
pub fn histogram_equalization( &self, gray: &[u8], width: u32, height: u32, ) -> Option<Vec<u8>>
Apply histogram equalization to an 8-bit grayscale image.
Returns None if gray.len() != width * height.
Sourcepub fn threshold_otsu(
&self,
gray: &[u8],
width: u32,
height: u32,
) -> Option<(u8, Vec<u8>)>
pub fn threshold_otsu( &self, gray: &[u8], width: u32, height: u32, ) -> Option<(u8, Vec<u8>)>
Compute Otsu’s optimal threshold and produce a binary image.
Returns (threshold, binary_image) or None on size mismatch.
Binary output: 0 for below-threshold, 255 for at/above.
Auto Trait Implementations§
impl Freeze for ComputeKernel
impl RefUnwindSafe for ComputeKernel
impl Send for ComputeKernel
impl Sync for ComputeKernel
impl Unpin for ComputeKernel
impl UnsafeUnpin for ComputeKernel
impl UnwindSafe for ComputeKernel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more