Skip to content

Commit ef433f3

Browse files
committed
Select by sum instead of max
1 parent 302601a commit ef433f3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/mediancut.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ impl<'hist> MedianCutter<'hist> {
300300
self.boxes.iter().enumerate()
301301
.filter(|(_, mbox)| mbox.colors.len() > 1)
302302
.map(move |(i, mbox)| {
303-
let cv = mbox.variance.r.max(mbox.variance.g).max(mbox.variance.b);
304-
let mut thissum = mbox.adjusted_weight_sum * f64::from(cv.max(mbox.variance.a));
303+
let mut thissum = mbox.adjusted_weight_sum * mbox.variance.iter().map(|f| f as f64).sum::<f64>();
305304
if f64::from(mbox.max_error) > max_mse {
306305
thissum = thissum * f64::from(mbox.max_error) / max_mse;
307306
}

0 commit comments

Comments
 (0)