JuliaGraphics / Colors.jl

Color manipulation utilities for Julia
Other
203 stars 45 forks source link

Luv and LCHuv gives incorrect color values for low lightness cyan #534

Open jensln opened 11 months ago

jensln commented 11 months ago

The Luv and LCHuv color spaces jumps to an unexpected hue even though the color parameters are constant and only the lightness is varying. These images speaks for themselves. Minimal reproducible example in Pluto, showing the incorrect colors:

image

Also visible in the website, choosing the relevant parameters, as demonstrated on my phone:

kimikage commented 5 months ago

Basically, Colors.jl does not perform gamut clamping in color conversion.

Since RGB{N0f8} can only represent the component values between 0 and 1, it is clamped by the component type restriction, but that does not imply "clamping by gamut”. In fact, RGB{Float64}(1.2, 0.0, -0.2) is a valid value in a sense (whether or not it is handled well).

Even if a color cannot be represented in RGB (especially sRGB), that color may be represented in other color models or color gamuts. Therefore, on the part of Luv, the value cannot be restricted without consensus or standard rules. In other words, this is a problem on the RGB side, the destination of the conversion.

However, as far as I know, there is no low-cost and accurate way to evaluate whether a given Luv color falls within the sRGB gamut. This is the reason why such false colors are left unchecked.

To begin with, the cost of conversion between Luv and RGB is expensive. The additional computing cost may not be a concern. I do not know about the labor costs.