Skip to content

Commit 9df9c10

Browse files
committed
Improve median filter's NaN handling by using total_cmp for safe comparisons
1 parent c8e5bd6 commit 9df9c10

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

node-graph/nodes/raster/src/filter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,6 @@ fn median_filter_algorithm(mut original_buffer: Image<Color>, radius: u32, gamma
246246
fn median_quickselect(values: &mut [f32]) -> f32 {
247247
let mid: usize = values.len() / 2;
248248
// nth_unstable is like quickselect: average O(n)
249-
*values.select_nth_unstable_by(mid, |a, b| a.partial_cmp(b).unwrap()).1
249+
// Use total_cmp for safe NaN handling instead of partial_cmp().unwrap()
250+
*values.select_nth_unstable_by(mid, |a, b| a.total_cmp(b)).1
250251
}

0 commit comments

Comments
 (0)