WithDilation

Trait WithDilation 

Source
pub trait WithDilation<S: RawData, const N: usize> {
    // Required method
    fn with_dilation(
        &self,
        dilation: impl IntoDilation<N>,
    ) -> KernelWithDilation<'_, S, N>;
}
Expand description

Trait for adding dilation information to a kernel.

Dilation is a parameter that controls the spacing between kernel elements during convolution. A dilation of 1 means no spacing (standard convolution), while larger values insert gaps between kernel elements.

§Example

use ndarray::array;
use ndarray_conv::{WithDilation, ConvExt, ConvMode, PaddingMode};

let input = array![1, 2, 3, 4, 5];
let kernel = array![1, 1, 1];

// Standard convolution (dilation = 1)
let result1 = input.conv(&kernel, ConvMode::Same, PaddingMode::Zeros).unwrap();

// Dilated convolution (dilation = 2)
let result2 = input.conv(kernel.with_dilation(2), ConvMode::Same, PaddingMode::Zeros).unwrap();

Required Methods§

Source

fn with_dilation( &self, dilation: impl IntoDilation<N>, ) -> KernelWithDilation<'_, S, N>

Adds dilation information to the kernel.

§Arguments
  • dilation: The dilation factor(s). Can be a single value (applied to all dimensions) or an array of values (one per dimension).
§Returns

A KernelWithDilation instance containing the kernel and dilation information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<S: RawData, const N: usize> WithDilation<S, N> for ArrayBase<S, Dim<[Ix; N]>>

Source§

fn with_dilation( &self, dilation: impl IntoDilation<N>, ) -> KernelWithDilation<'_, S, N>

Implementors§