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

Function quality_to_mse

src/quant.rs:466–473  ·  view source on GitHub ↗
(quality: u8)

Source from the content-addressed store, hash-verified

464}
465
466pub(crate) fn quality_to_mse(quality: u8) -> f64 {
467 if quality == 0 {
468 return 1e20; // + epsilon for floating point errors
469 }
470 if quality >= 100 { return 0.; }
471 let extra_low_quality_fudge = (0.016 / (0.001 + f64::from(quality)) - 0.001).max(0.);
472 LIQ_WEIGHT_MSE * (extra_low_quality_fudge + 2.5 / (210. + f64::from(quality)).powf(1.2) * (100.1 - f64::from(quality)) / 100.)
473}
474
475pub(crate) fn mse_to_quality(mse: f64) -> u8 {
476 for i in (1..101).rev() {

Callers 5

cutMethod · 0.85
find_best_paletteFunction · 0.85
mse_to_qualityFunction · 0.85
set_qualityMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected