Skip to content

Commit e3007a7

Browse files
committed
Avoid confusing divisor
1 parent 6aad8f2 commit e3007a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl Histogram {
320320

321321
// Limit perceptual weight to 1/10th of the image surface area to prevent
322322
// a single color from dominating all others.
323-
let max_perceptual_weight = 0.1 * (temp.iter().map(|t| f64::from(t.weight)).sum::<f64>() / 256.) as f32;
323+
let max_perceptual_weight = ((0.1 / 255.) * temp.iter().map(|t| f64::from(t.weight)).sum::<f64>()) as f32;
324324

325325
let lut = gamma_lut(gamma);
326326
let mut total_perceptual_weight = 0.;
@@ -331,9 +331,9 @@ impl Histogram {
331331

332332
// weight == 0 means it's a fixed color
333333
let weight = if temp_item.weight > 0. {
334-
(temp_item.weight * (1. / 256.)).min(max_perceptual_weight)
334+
(temp_item.weight * (1. / 255.)).min(max_perceptual_weight)
335335
} else {
336-
max_perceptual_weight * 10.
336+
max_perceptual_weight * 16.
337337
};
338338
total_perceptual_weight += f64::from(weight);
339339

0 commit comments

Comments
 (0)