-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
TL;DR, data with smooth gradients that is u16 or f32 per channel may exhibit banding when converted to u8 (even for the common case that the target space for the u8 data is non-linear).
There should be a way to either enable dithering when converting or to specify a custom way to do the dithering (e.g. a closure).
I would think that by default a random dither of some sort should be available and this could then be optimized (SIMD & co).
/// Assuming `value` is `f32` and could be
/// outside `0.0..1.0`.
let value: u8 = (
u8::MAX as f32 * value +
dither_amplitude * rng.gen_range(-1.0..1.0)()
)
.round()
.clamp(u8::MIN, u8::MAX) as _;A typical default for dither_amplitude is 0.5.
Metadata
Metadata
Assignees
Labels
No labels