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

Improve accuracy of delta_h for large hue differences #503

Merged
merged 1 commit into from
Jul 24, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Jul 23, 2021

This is a follow-up to PR #501.
This avoids the loss of significance when |Δh| > 90 deg.
This also adds delta_c to improve accuracy of Lab{Float32} chroma differences.

julia> a, b = Lab(60, -36.75124f0, -4.8861504f0), Lab(80, 4.557669f0, -2.6522517f0);

julia> Colors.delta_h(a, b)
-26.459148f0 # master
-26.459143f0 # this PR

julia> Colors.delta_h(Lab{BigFloat}(a), Lab{BigFloat}(b))
-26.45914388977270124791437895470628506022253442451544986697371328558951044881593

julia> chroma(a) - chroma(b)
31.801413f0

julia> Colors.delta_c(a, b)
31.801414f0

julia> chroma(Lab{BigFloat}(a)) - chroma(Lab{BigFloat}(b))
31.80141452063303790359376637963574569550424247180931525255208635027325242378461

This avoids the loss of significance when |Δh| > 90 deg.
This also adds `delta_c` to improve accuracy of `Lab{Float32}` chroma differences.
@codecov
Copy link

codecov bot commented Jul 23, 2021

Codecov Report

Merging #503 (c4dafa0) into master (f38f27c) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #503      +/-   ##
==========================================
+ Coverage   93.60%   93.64%   +0.04%     
==========================================
  Files           9        9              
  Lines        1111     1118       +7     
==========================================
+ Hits         1040     1047       +7     
  Misses         71       71              
Impacted Files Coverage Δ
src/utilities.jl 98.68% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f38f27c...c4dafa0. Read the comment docs.

@kimikage kimikage merged commit 2a0b92d into JuliaGraphics:master Jul 24, 2021
@kimikage kimikage deleted the delta_h_accuracy2 branch July 24, 2021 01:22
@kimikage
Copy link
Collaborator Author

kimikage commented Jul 24, 2021

A: 2 * muladd(c1, c2, -dp)
B: muladd(dc, -dc, muladd(da, da, db^2))

When comparing A and B, A is generally more accurate because it only subtracts once. However, even A can lose digits, in which case B can be more accurate. 😕

Edit: I retuned it in PR #494. 😅
Edit2: I also fixed the typo in the comment about the talyor series. 😭

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.

1 participant