Closed mkitti closed 1 week ago
Further thought: perhaps a general Inverted{T}
type would be a good idea.
I would support adding a general Inverted{T}
type, but are there any examples of inverted RGB, etc? I haven't seen such a thing.
I believe there is a general concept of inverting a RGB value.
https://pinetools.com/invert-color
Also we already have ColorVectorSpace.complement
.
julia> using ColorVectorSpace
julia> complement(Gray(1))
Gray{N0f8}(0.0)
julia> complement(RGB(0.75, 0.25, 0))
RGB{Float64}(0.25,0.75,1.0)
Maybe this should be called Complement{T}
and be a lazy version of complement
?
Now I'm wondering if we're at the wrong package. Maybe this should also be in ColorVectorSpace.jl?
Honestly @timholy or @johnnychen94 would know better than me, but a lazy complement
might be a general solution to this.
Yeah, given that complement
is in ColorVectorSpace, let's add a Complement{T,N,C<:Colorant{T,N}}} <: Colorant{T,N}
there. It's a bit of a pity that we can't just call this Complement{C}
and preserve the subtyping, but perhaps there's some clever typealiasing that could be done?
Prototype is here: https://github.com/JuliaGraphics/ColorVectorSpace.jl/pull/189
A practical case, where inverted representations other than Gray are used is CMYK.
However, I am against implementing CMYK
in ColorTypes.jl
. (cf. https://github.com/JuliaGraphics/ColorTypes.jl/issues/179#issuecomment-616886589)
(Note that CMYK in TIFF is not a situation where Complement
is needed, since TIFF recommends mapping 255
to 100% ink coverage, i.e., follows the "main-stream" representation.)
I'm considering an
InvertedGray <: AbstractGray
type that has the intepretation that lower values correspond to white.I encountered this need in https://github.com/tlnagy/TiffImages.jl/pull/134