pub struct ConvolutionKernel {
pub size: u32,
pub values: Vec<f32>,
pub divisor: f32,
pub bias: f32,
pub preserve_alpha: bool,
}Expand description
Convolution kernel for custom filtering operations.
Defines a square matrix of weights used for convolution-based image processing. The kernel is applied to each pixel by multiplying surrounding pixels by the weights, summing the results, dividing by the divisor, and adding the bias.
Fields§
§size: u32Kernel size (e.g., 3 for a 3×3 kernel, 5 for 5×5). The kernel must be square, so this defines both width and height.
values: Vec<f32>Kernel weight values in row-major order. Length must equal size × size. Center of kernel is typically at (size/2, size/2).
divisor: f32Normalization divisor applied to the convolution result. Common practice is to use the sum of all weights for averaging, or 1.0 otherwise.
bias: f32Bias value added to the result after normalization. Useful for edge detection or emboss effects to shift the result range.
preserve_alpha: boolWhether to preserve the alpha channel unchanged. If true, convolution only applies to RGB; if false, it applies to RGBA.
Trait Implementations§
Source§impl Clone for ConvolutionKernel
impl Clone for ConvolutionKernel
Source§fn clone(&self) -> ConvolutionKernel
fn clone(&self) -> ConvolutionKernel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConvolutionKernel
impl Debug for ConvolutionKernel
Source§impl PartialEq for ConvolutionKernel
impl PartialEq for ConvolutionKernel
Source§fn eq(&self, other: &ConvolutionKernel) -> bool
fn eq(&self, other: &ConvolutionKernel) -> bool
self and other values to be equal, and is used by ==.