Skip to content

Commit

Permalink
Akaze: Fixed simple Scharr filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanemagnenat committed Jun 13, 2023
1 parent a94a9a4 commit 33383f7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions akaze/src/contrast_factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub fn compute_contrast_factor(
let mut num_points: f64 = 0.0;
let mut histogram = vec![0; num_bins];
let gaussian = gaussian_blur(image, gradient_histogram_scale as f32);
let Lx = crate::derivatives::scharr_horizontal(&gaussian, 1);
let Ly = crate::derivatives::scharr_vertical(&gaussian, 1);
let Lx = crate::derivatives::simple_scharr_horizontal(&gaussian);
let Ly = crate::derivatives::simple_scharr_vertical(&gaussian);
let hmax = (1..gaussian.height() - 1)
.flat_map(|y| (1..gaussian.width() - 1).map(move |x| (x, y)))
.map(|(x, y)| Lx.get(x, y).powi(2) as f64 + Ly.get(x, y).powi(2) as f64)
Expand Down
18 changes: 18 additions & 0 deletions akaze/src/derivatives.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
use crate::image::{fill_border, GrayFloatImage};
use ndarray::{s, Array2, ArrayView2, ArrayViewMut2};

pub fn simple_scharr_horizontal(image: &GrayFloatImage) -> GrayFloatImage {
// similar to cv::Scharr with xorder=1, yorder=0, scale=1, delta=0
GrayFloatImage(imageproc::filter::separable_filter(
&image.0,
&[-1., 0., 1.],
&[3., 10., 3.],
))
}

pub fn simple_scharr_vertical(image: &GrayFloatImage) -> GrayFloatImage {
// similar to cv::Scharr with xorder=0, yorder=1, scale=1, delta=0
GrayFloatImage(imageproc::filter::separable_filter(
&image.0,
&[3., 10., 3.],
&[-1., 0., 1.],
))
}

/// Compute the Scharr derivative horizontally
///
/// The implementation of this function is using a separable kernel, for speed.
Expand Down
4 changes: 2 additions & 2 deletions akaze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ impl Akaze {
}
evolutions[i].Lsmooth = gaussian_blur(&evolutions[i].Lt, 1.0f32);
trace!("Gaussian blur finished.");
evolutions[i].Lx = derivatives::scharr_horizontal(&evolutions[i].Lsmooth, 1);
evolutions[i].Lx = derivatives::simple_scharr_horizontal(&evolutions[i].Lsmooth);
trace!("Computing derivative Lx done.");
evolutions[i].Ly = derivatives::scharr_vertical(&evolutions[i].Lsmooth, 1);
evolutions[i].Ly = derivatives::simple_scharr_vertical(&evolutions[i].Lsmooth);
trace!("Computing derivative Ly done.");
evolutions[i].Lflow = pm_g2(&evolutions[i].Lx, &evolutions[i].Ly, contrast_factor);
trace!("Lflow finished.");
Expand Down

0 comments on commit 33383f7

Please sign in to comment.