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

Method kmeans_iterations

src/attr.rs:307–327  ·  view source on GitHub ↗
(&self, hist_items_len: usize, palette_error_is_known: bool)

Source from the content-addressed store, hash-verified

305 /// returns iterations, `iteration_limit`
306 #[must_use]
307 pub(crate) fn kmeans_iterations(&self, hist_items_len: usize, palette_error_is_known: bool) -> (u16, f64) {
308 let mut iteration_limit = self.kmeans_iteration_limit;
309 let mut iterations = self.kmeans_iterations;
310 if hist_items_len > 5000 {
311 iterations = (iterations * 3 + 3) / 4;
312 }
313 if hist_items_len > 25000 {
314 iterations = (iterations * 3 + 3) / 4;
315 }
316 if hist_items_len > 50000 {
317 iterations = (iterations * 3 + 3) / 4;
318 }
319 if hist_items_len > 100_000 {
320 iterations = (iterations * 3 + 3) / 4;
321 iteration_limit *= 2.;
322 }
323 if iterations == 0 && !palette_error_is_known && self.max_mse.is_some() {
324 iterations = 1;
325 }
326 (iterations, iteration_limit)
327 }
328
329 #[inline]
330 #[must_use]

Callers 2

refine_paletteFunction · 0.80
countersFunction · 0.80

Calls

no outgoing calls

Tested by 1

countersFunction · 0.64