From c8c71cc07e21a27eadf3d88bac7dc5e1cd5c1b55 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Wed, 28 Oct 2026 19:36:55 +0000 Subject: [PATCH] Use convolve_sat in canny and sobel --- src/filter/canny.rs | 2 +- src/filter/sobel.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/filter/canny.rs b/src/filter/canny.rs index 26ddc9d..ec82c87 100644 --- a/src/filter/canny.rs +++ b/src/filter/canny.rs @@ -11,7 +11,7 @@ use crate::kernel::Kernel; use crate::*; pub fn canny(img: Image) -> Image { - let blurred = kernel::gaussian::<5>(2.0).convolve(&img); + let blurred = kernel::gaussian::<5>(1.4).convolve_sat(&img); let sobel = filter::sobel(blurred); let maxima = gradient_threshold(sobel); let candidates = double_threshold(maxima); diff --git a/src/filter/sobel.rs b/src/filter/sobel.rs index d8154fa..cb4def0 100644 --- a/src/filter/sobel.rs +++ b/src/filter/sobel.rs @@ -23,8 +23,8 @@ const KERNEL_Y: [[f32; 3]; 3] = [[-1.0, -2.0, -1.0], [0.0, 0.0, 0.0], [1.0, 2.0, 1.0]]; pub fn sobel(img: Image) -> Image { - let x_edges = KERNEL_X.convolve(&img); - let y_edges = KERNEL_Y.convolve(&img); + let x_edges = KERNEL_X.convolve_sat(&img); + let y_edges = KERNEL_Y.convolve_sat(&img); let mut result = image::Image::::with_extent(x_edges.extent); result.for_each(|x, y, p| {