Skip to content

Commit

Permalink
crates/imageprocs/bilateral_filter: Calculate mid correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
etemesi254 committed Jan 7, 2024
1 parent 8ffaf8d commit 54cc956
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/zune-imageprocs/src/bilateral_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ fn bilateral_filter_int<T>(
//pad here
let padded_input = pad(src, width, height, radius, radius, PadMethod::Replicate);

let mid = (radius + 1) / 2;

// use an inner lambda to implement the bilateral loop as it allows us to borrow
// surrounding variables

Expand All @@ -249,6 +247,8 @@ fn bilateral_filter_int<T>(
// This impl matches opencv bilateral_filter's inner loop, with less pointer chasing as
// the spatial function sends the right thing to us
let bilateral_func = |area: &[T]| -> T {
let mid = (area.len() + 1) / 2;

let mut sum = 0.0;
let mut wsum = 0.0;
let val0 = i32::from(area[mid]);
Expand Down

0 comments on commit 54cc956

Please sign in to comment.