pub fn convolution(
img: &PhotonImage,
filter: Filter,
stride: u32,
padding: PaddingType,
) -> PhotonImageExpand description
Applies convolution to an image using the given filter.
Each path (separable 1D and standard 2D) is parallelised across output rows via rayon — no data dependencies between rows, trivially parallel.
§Speedup Examples
| Kernel | Size | Sequential | Rayon (8 cores) |
|---|---|---|---|
| Gauss | 7×7 | 61 ms | ~8 ms |
| Gauss | 15×15 | 94 ms | ~12 ms |
| Laplacian | 3×3 | 47 ms | ~6 ms |
§Example
use image_conv::conv;
use image_conv::{Filter, PaddingType};
let img = photon_rs::native::open_image("img.jpg").expect("No such file found");
let sobel_x: Vec<f32> = vec![1.0, 0.0, -1.0, 2.0, 0.0, -2.0, 1.0, 0.0, -1.0];
let filter = Filter::from(sobel_x, 3, 3);
let img_conv = conv::convolution(&img, filter, 1, PaddingType::UNIFORM(1));