Skip to main content

Module convolution

Module convolution 

Source
Expand description

2D convolution and correlation with border handling, the shared basis of the image filters.

Images are Array2<f64> indexed (row, column). Kernels have odd dimensions and are centred on the output pixel. Pixels outside the image are supplied according to a Border mode. Direct (spatial) evaluation is used; for large kernels see fft_convolve_2d.

See the book entry Image filtering.

Enums§

Border
How to supply pixels beyond the image edge.

Functions§

border_index
Maps a possibly out-of-range index into 0..n for a border mode (None means “zero”).
convolve2d
2D convolution (the kernel is flipped in both axes), output the same size as the input.
correlate2d
2D cross-correlation (the kernel is not flipped): out[r, c] = Σ image[r+i, c+j] · kernel[i+hr, j+hc].
gaussian_kernel_1d
A normalised 1D Gaussian kernel with standard deviation sigma (in pixels), truncated at truncate standard deviations (4 is conventional) and always of odd length.
separable_convolve
Separable filtering: convolves every row with row_kernel and then every column with col_kernel (both odd length, symmetric or not; true convolution).