Closed kmsquire closed 9 years ago
Thanks for this, it's obviously a step forward. Getting the logic of these conversions right, with so many different types, is surprisingly tricky. Thanks for cleaning up my mess!
NP! I had actually worked my way here from Images
, after trying
julia> convert(Image{Lab}, img)
ERROR: type: Lab: in T, expected T<:FloatingPoint, got Type{UfixedBase{Uint8,8}}
in _convert at /home/kevin/.julia/v0.4/Images/src/core.jl:204
in convert at /home/kevin/.julia/v0.4/Images/src/core.jl:200
You have some pretty convoluted code in there to try to mimic triangle dispatch. :-)
I worked through it somewhat, but it looks like the Color array conversion should be moved to this package, and then dealt with in a similar way to this patch. Thoughts?
I've updated according to your comments, Tim. If there's nothing else, I'll squash and merge in a little while.
Looks great to me.
Yes, the type handling was easily the trickiest part about the recent migration. If there had been an easier syntax for triangular dispatch, it would indeed have been simpler.
Regarding stuff to move here, are you referring to some of the functions in Images/src/core.jl
(reinterpret
and convert
), or to stuff in Images/src/colortypes.jl
? I think I'm not seeing the precise material you're describing. But overall I agree it's not clear what should be where, and certainly more stuff should probably come here.
ColorValue{Ufixed}
types to abstractColorValue
s (i.e., without a specified type parameter) failed (these conversions are allowed fromColorValue{FloatingPoint}
types)ColorValue{Ufixed}
toColorValue{FloatingPoint}
did not round trip well (e.g.,RGB{Ufixed8}
->Lab{Float64}
->RGB{Ufixed8}
)Previously:
With this PR:
While the behavior is obviously better, this may not be the right fix, so I would appreciate feedback.
Cc: @timholy