Skip to content
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

Add Oklab perceptual color space #271

Closed
wants to merge 10 commits into from

Conversation

nealmckee
Copy link

@nealmckee nealmckee commented Jan 1, 2022

Implements the Oklab color space as described here: https://bottosson.github.io/posts/oklab/

Adds and exports the type.
Adds Oklab and LCHOklab to the chroma and hue trait accessor functions.
Adds description to the readme.

This is my first contribution to Julia, or any software package for that matter, so help with any oversights would be greatly appreciated. (Am I missing tests for example? They weren’t mentioned in the guidelines on how to extend color types.)

See also JuliaGraphics/Colors.jl#518

Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about color spaces so can't give detailed feedback here.

They're a list of traits in https://github.com/JuliaGraphics/ColorTypes.jl#traits-utility-functions-for-instances-and-types. Maybe you can check and implement all of them that make sense for Oklab and LCHOklab? Conversions between Oklab/LCHklab from/to other color spaces might also need to be supported.

Tests are needed to ensure things work as expected.

chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Luv} = sqrt(c.u^2 + c.v^2)
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv}} = c.c
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv, LCHOklab}} = c.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv, LCHOklab}} = c.c
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv,LCHOklab}} = c.c


"""
`hue(c)` returns the hue in degrees. This function does not guarantee that the
return value is in [0, 360].
"""
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv}} = c.h
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{Lab,DIN99,DIN99o,DIN99d}} =
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv, LCHOklab}} = c.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv, LCHOklab}} = c.h
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv,LCHOklab}} = c.h

@tecosaur
Copy link
Contributor

@nealmckee is there a reason why this is still a draft PR?

@eprovst eprovst mentioned this pull request Aug 1, 2023
@timholy
Copy link
Member

timholy commented Aug 2, 2023

Superseded by #291

@timholy timholy closed this Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants