Struct Kernel

Source
pub struct Kernel { /* private fields */ }
Expand description

2-dimensional convolution kernel

Implementations§

Source§

impl Kernel

Source

pub fn new(rows: usize, cols: usize) -> Kernel

Create a new kernel with the given number of rows and columns

Source

pub fn square(x: usize) -> Kernel

Create a new, square kernel

Source

pub fn normalize(&mut self)

Ensures the sum of the kernel is <= 1

Source

pub fn create<F: Fn(usize, usize) -> f64>( rows: usize, cols: usize, f: F, ) -> Kernel

Create a new kernel and fill it by executing f with each possible (row, col) pair

Source

pub fn gaussian(n: usize, std: f64) -> Kernel

Generate gaussian blur kernel

Source

pub fn gaussian_3x3() -> Kernel

3x3 pixel gaussian blur

Source

pub fn gaussian_5x5() -> Kernel

5x5 pixel gaussian blur

Source

pub fn gaussian_7x7() -> Kernel

7x7 pixel gaussian blur

Source

pub fn gaussian_9x9() -> Kernel

9x9 pixel gaussian blur

Source

pub fn sobel_x() -> Kernel

Sobel X

Source

pub fn sobel_y() -> Kernel

Sobel Y

Source

pub fn laplacian() -> Kernel

Laplacian

Source

pub fn sobel() -> Kernel

Sobel X and Y combined

Trait Implementations§

Source§

impl Add for Kernel

Source§

type Output = Kernel

The resulting type after applying the + operator.
Source§

fn add(self, other: Kernel) -> Kernel

Performs the + operation. Read more
Source§

impl Clone for Kernel

Source§

fn clone(&self) -> Kernel

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Kernel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Kernel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div for Kernel

Source§

type Output = Kernel

The resulting type after applying the / operator.
Source§

fn div(self, other: Kernel) -> Kernel

Performs the / operation. Read more
Source§

impl<T: Type, C: Color, U: Type, D: Color> Filter<T, C, U, D> for Kernel

Source§

fn schedule(&self) -> Schedule

Determines whether a filter should be executed one pixel at a time, or a whole image at a time
Source§

fn compute_at( &self, pt: Point, input: &Input<'_, T, C>, dest: &mut DataMut<'_, U, D>, )

Compute filter at the given point for the provided input Read more
Source§

fn output_size(&self, _input: &Input<'_, T, C>, dest: &mut Image<U, D>) -> Size

Get filter output size, this is typically the destination image size, however when used as part of a pipeline a single filter might have a different output size
Source§

fn eval_partial( &self, roi: Region, input: &[&Image<T, C>], output: &mut Image<U, D>, )

Evaluate a filter on part of an image
Source§

fn eval_partial_in_place(&self, roi: Region, output: &mut Image<U, D>)

Evaluate filter on part of an image using the same image for input and output
Source§

fn eval(&self, input: &[&Image<T, C>], output: &mut Image<U, D>)

Evaluate filter
Source§

fn eval_in_place(&self, output: &mut Image<U, D>)

Evaluate filter using the same image for input and output
Source§

impl<'a> From<&'a [&'a [f64]]> for Kernel

Source§

fn from(data: &'a [&'a [f64]]) -> Kernel

Converts to this type from the input type.
Source§

impl<const N: usize> From<[[f64; N]; N]> for Kernel

Source§

fn from(data: [[f64; N]; N]) -> Kernel

Converts to this type from the input type.
Source§

impl From<Vec<Vec<f64>>> for Kernel

Source§

fn from(data: Vec<Vec<f64>>) -> Kernel

Converts to this type from the input type.
Source§

impl Mul for Kernel

Source§

type Output = Kernel

The resulting type after applying the * operator.
Source§

fn mul(self, other: Kernel) -> Kernel

Performs the * operation. Read more
Source§

impl PartialEq for Kernel

Source§

fn eq(&self, other: &Kernel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Kernel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub for Kernel

Source§

type Output = Kernel

The resulting type after applying the - operator.
Source§

fn sub(self, other: Kernel) -> Kernel

Performs the - operation. Read more
Source§

impl StructuralPartialEq for Kernel

Auto Trait Implementations§

§

impl Freeze for Kernel

§

impl RefUnwindSafe for Kernel

§

impl Send for Kernel

§

impl Sync for Kernel

§

impl Unpin for Kernel

§

impl UnwindSafe for Kernel

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, C, U, D, F> FilterExt<T, C, U, D> for F
where T: Type, C: Color, U: Type, D: Color, F: Filter<T, C, U, D>,

Source§

fn to_async<'a>( &'a self, mode: AsyncMode, input: Input<'a, T, C>, output: &'a mut Image<U, D>, ) -> AsyncFilter<'a, Self, T, C, U, D>

Convert filter to AsyncFilter
Source§

fn then(self, other: impl 'static + Filter<T, C, U, D>) -> Pipeline<T, C, U, D>
where Self: 'static,

Create a new pipeline
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,