-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC/WIP] Add abstract types for gamut definitions (#139) #140
Conversation
We can generate the random julia> rand(LabA)
LabA{Float64}(22.480820110815625,13.641014129939421,-5.753612633740147,0.23049096545302006) We can override the default range of color space (in a somewhat tricky manner). julia> ColorTypes.gamutmax(::Type{<:Lab}) = (100,200,200)
julia> rand(Lab)
Lab{Float64}(76.07250064744058,192.4625550050896,5.393193026026793) |
gamutmax(::Type{<:YIQ}, ::Type{Gamut_sRGB}) = (1,0.5957,0.5226) | ||
gamutmin(::Type{<:YIQ}, ::Type{Gamut_sRGB}) = (0,-0.5957,-0.5226) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The color primaries of NTSC and sRGB are different, and the NTSC color gamut is actually wider than sRGB's one. However, this difference is often ignored as "RGB" does not explicitly conform the sRGB.
Therefore, the following measures can be considered:
- Set the default color gamut for
YIQ
toGamut_NTSC
(orGamut_SMPTE_C
) - Narrow the range to be correct as sRGB
In any case, the gamut conflicts with the conversion methods in Colors.jl
.
gamutmax(::Type{<:AbstractGray}, ::Type{Gamut_sRGB}) = (1,) | ||
gamutmin(::Type{<:AbstractGray}, ::Type{Gamut_sRGB}) = (0,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking, sRGB should not specify the so-called gray range. The range of luminance Y
is [0,1], but Y
is different from the so-called gray.
This also changes the `gamutmin`/`gamutmax` definitions.
Codecov Report
@@ Coverage Diff @@
## master #140 +/- ##
==========================================
- Coverage 86.53% 83.82% -2.71%
==========================================
Files 6 8 +2
Lines 490 581 +91
==========================================
+ Hits 424 487 +63
- Misses 66 94 +28
Continue to review full report at Codecov.
|
I'm going to rename "gamut.jl" -> "gamuts.jl". |
I like the simplicity of this design 👍 |
Co-Authored-By: Johnny Chen <johnnychen94@hotmail.com>
I prioritize extending Colors.jl and close this PR.(cf. #139 (comment)) |
This adds abstract types for the gamut definitions (cf. #139, #125).
This also changes the
gamutmin
/gamutmax
definitions. The newgamutmin
/gamutmax
mean the corners of the minimum bounding box of the (implicitly) specified gamut. Specifying the gamut (i.e. "sRGB") specifies the range somewhat formally.Edit:
Of course, if we allow breaking changes, we also have the option of moving these to
Colors.jl
. I thinkrand()
(with gamuts) is too complex forColorTypes.jl
, a minimal package.