Use convolve_sat in canny and sobel

This commit is contained in:
cdo committed 2026-10-28 19:40:14 +00:00
1 parent 5b940c2192
commit c8c71cc07e
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ use crate::kernel::Kernel;
use crate::*; use crate::*;
pub fn canny(img: Image<Luminance>) -> Image<Luminance> { pub fn canny(img: Image<Luminance>) -> Image<Luminance> {
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 sobel = filter::sobel(blurred);
let maxima = gradient_threshold(sobel); let maxima = gradient_threshold(sobel);
let candidates = double_threshold(maxima); let candidates = double_threshold(maxima);
+2 -2
View File
@@ -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]]; [[-1.0, -2.0, -1.0], [0.0, 0.0, 0.0], [1.0, 2.0, 1.0]];
pub fn sobel(img: Image<Luminance>) -> Image<Vector> { pub fn sobel(img: Image<Luminance>) -> Image<Vector> {
let x_edges = KERNEL_X.convolve(&img); let x_edges = KERNEL_X.convolve_sat(&img);
let y_edges = KERNEL_Y.convolve(&img); let y_edges = KERNEL_Y.convolve_sat(&img);
let mut result = image::Image::<Vector>::with_extent(x_edges.extent); let mut result = image::Image::<Vector>::with_extent(x_edges.extent);
result.for_each(|x, y, p| { result.for_each(|x, y, p| {