Skip to content

Commit

Permalink
Akaze: Use imageproc functions for computing Gaussian blur.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanemagnenat committed Jun 13, 2023
1 parent 33383f7 commit bf36926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions akaze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ float-ord = { version = "0.3.2", default-features = false }
space = "0.17.0"
bitarray = "0.9.0"
thiserror = { version = "1.0.40", default-features = false }
imageproc = "0.23.0"


[dev-dependencies]
Expand Down
11 changes: 6 additions & 5 deletions akaze/src/image.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use derive_more::{Deref, DerefMut};
use image::{DynamicImage, ImageBuffer, Luma, Pixel};
use image::{DynamicImage, ImageBuffer, Luma};
use imageproc::filter::separable_filter_equal;
use log::*;
use ndarray::{azip, s, Array2, ArrayView2, ArrayViewMut2};
use nshare::{MutNdarray2, RefNdarray2};
Expand Down Expand Up @@ -310,11 +311,11 @@ fn gaussian_kernel(r: f32, kernel_size: usize) -> Vec<f32> {
/// # Return value
/// The resulting image after the filter was applied.
pub fn gaussian_blur(image: &GrayFloatImage, r: f32) -> GrayFloatImage {
// a separable Gaussian kernel
let kernel_size = (f32::ceil(r) as usize) * 2 + 1usize;
assert!(r > 0.0, "sigma must be > 0.0");
let kernel_radius = (2.0 * r).ceil() as usize;
let kernel_size = kernel_radius * 2 + 1;
let kernel = gaussian_kernel(r, kernel_size);
let img_horizontal = horizontal_filter(image, &kernel);
vertical_filter(&img_horizontal, &kernel)
GrayFloatImage(separable_filter_equal(image, &kernel))
}

#[cfg(test)]
Expand Down

0 comments on commit bf36926

Please sign in to comment.