// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// Desaturate out-of-gamut pixels. This is done by mixing each pixel // with just enough gray of the target luminance to make all // components non-negative. // - For saturation preservation, if a component is still larger than // 1 then the pixel is normalized to have a maximum component of 1. // That will reduce its luminance. // - For luminance preservation, getting all components below 1 is // done by mixing in yet more gray. That will desaturate it further. float gray_mix_saturation = 0.0f; float gray_mix_luminance = 0.0f; for (size_t idx : {0, 1, 2}) { constfloat& val = rgb[idx]; constfloat val_minus_gray = val - luminance; constfloat inv_val_minus_gray =
1.0f / ((val_minus_gray == 0.0f) ? 1.0f : val_minus_gray); constfloat val_over_val_minus_gray = val * inv_val_minus_gray;
gray_mix_saturation =
(val_minus_gray >= 0.0f)
? gray_mix_saturation
: std::max(gray_mix_saturation, val_over_val_minus_gray);
gray_mix_luminance =
std::max(gray_mix_luminance,
(val_minus_gray <= 0.0f)
? gray_mix_saturation
: (val_over_val_minus_gray - inv_val_minus_gray));
} constfloat gray_mix =
Clamp1((preserve_saturation * (gray_mix_saturation - gray_mix_luminance) +
gray_mix_luminance),
0.0f, 1.0f); for (size_t idx : {0, 1, 2}) { float& val = rgb[idx];
val = gray_mix * (luminance - val) + val;
} constfloat max_clr = std::max({1.0f, rgb[0], rgb[1], rgb[2]}); constfloat normalizer = 1.0f / max_clr; for (size_t idx : {0, 1, 2}) {
rgb[idx] *= normalizer;
}
}
} // namespace jxl
#endif// LIB_JXL_CMS_TONE_MAPPING_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.