JuliaGraphics / Colors.jl

Color manipulation utilities for Julia
Other
204 stars 44 forks source link

unexpected results inconvert RGB -> [DIN99d,DIN99dA,ADIN99d] -> RGB #256

Closed hofmannmartin closed 5 years ago

hofmannmartin commented 7 years ago

Normally, I would expect that the conversion c1::TypeA -> c2::TypeB -> c3::TypeA yields that c1 is approximately equal to c3. However for the types above one gets

julia> convert(RGB,convert(DIN99d,RGB(1,0.5,0)))
RGB{Float64}(0.5618900556828353,0.660676085072947,0.6265900923320097)

julia> convert(RGBA,convert(DIN99dA,RGBA(1,0.5,0,0.4)))
RGBA{Float64}(0.5618900556828353,0.660676085072947,0.6265900923320097,0.4)

which suggests, that there is a problem with the conversion RGB<->DIN99d.

m-lohmann commented 7 years ago

I worked on DIN99 (originally Glenn Sweeney) and implemented DIN99o back then... I’ll have a look at the DIN99d conversion. Probably the intermediate conversion step to XYZ is causing the problem.

Found the culprit: Several errors, rotation in wrong direction, one wrong sign in function cnvt{T}(::Type{XYZ{T}}, c::DIN99d)

This is what you get now:

julia> convert(RGB,convert(DIN99d,RGB(1,0.5,0.0)))
RGB{Float64}(0.9999999224685044,0.5000001510720956,0.0)

Should be fixed now.

hofmannmartin commented 7 years ago

Thank you very much. Could you make a pull request for your patch?

m-lohmann commented 7 years ago

I thought I already had. Something must have gone wrong. I'll make a pull request as soon as I can.

Edit: Done