MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / finalize

Method finalize

src/kmeans.rs:42–51  ·  view source on GitHub ↗
(self, palette: &mut PalF)

Source from the content-addressed store, hash-verified

40 }
41
42 pub fn finalize(self, palette: &mut PalF) -> f64 {
43 for (avg, (color, pop)) in self.averages.iter().zip(palette.iter_mut()).filter(|(_, (_, pop))| !pop.is_fixed()) {
44 let total = avg.total;
45 *pop = PalPop::new(total as f32);
46 if total > 0. && color.a != 0. {
47 *color = avg.sum.map(move |c| (c / total) as f32).into();
48 }
49 }
50 self.weighed_diff_sum
51 }
52
53 #[inline(never)]
54 pub(crate) fn iteration(hist: &mut HistogramInternal, palette: &mut PalF, adjust_weight: bool) -> Result<f64, Error> {

Callers 2

remap_to_paletteFunction · 0.45
iterationMethod · 0.45

Calls 3

newFunction · 0.85
iter_mutMethod · 0.80
is_fixedMethod · 0.80

Tested by

no test coverage detected