Closed my-little-repository closed 10 years ago
The error stems from roundoff error in the computation of cp
for gamma correction, where cp==-1.2215685532136273e-16<0
.
Specifically, the numerator is causing this roundoff error on that line:
(alpha * un + beta * vn) * a2 - a1 => -1.1102230246251565e-16
which is smaller than eps() == 2.220446049250313e-16
. Thresholding cp
to be nonnegative would solve this problem, although it strikes me as somewhat inelegant.
It also just occurred to me that the numerator is exactly -0.5*eps()
.
Sorry for jumping in so late, I have completely missed this issue and been somewhat buried under work stuff.
As you said, it seems that the algorithm by Wijffelaars, M., et al. (2008) is numerically unstable. One simple fix that comes into my mind would just be to return the color immediately if it is directly on the corner of the color space like blue is in this case.
Fixed by @natj in #19.
The MSC function returns an error when tested with a blue hue (red and green are ok).
julia> MSC(convert(LCHuv,color("blue")).h) ERROR: DomainError in MSC at /home/yves/.julia/Color/src/Color.jl:1039
I think we should obtain the same value for
convert(LCHuv,color("blue").h
and its MSC hue value since blue is on the edge of the RGB cube. There is a big ratio in the computation of MSC, so maybe this is a case where this ratio evaluates to 0/0.