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

Optimize pow5_12(::Float32) #493

Merged
merged 1 commit into from
Jun 23, 2021
Merged

Conversation

kimikage
Copy link
Collaborator

Without PR #482, pow5_12(::Float32) was never called because linear RGB values are promoted to Float64 in the transform matrix multiplication.
The new pow5_12(::Float32) has an accuracy of about 0.5 ULP.

@codecov
Copy link

codecov bot commented Jun 20, 2021

Codecov Report

Merging #493 (c4ae4f9) into master (9710272) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #493      +/-   ##
==========================================
+ Coverage   93.40%   93.47%   +0.06%     
==========================================
  Files           9        9              
  Lines        1061     1072      +11     
==========================================
+ Hits          991     1002      +11     
  Misses         70       70              
Impacted Files Coverage Δ
src/conversions.jl 99.38% <100.00%> (+<0.01%) ⬆️
src/utilities.jl 98.93% <100.00%> (+0.06%) ⬆️

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 9710272...c4ae4f9. Read the comment docs.

@kimikage
Copy link
Collaborator Author

Benchmark

cf. #482 (comment)

julia> @btime convert.(RGB, $xyz_f32);
  36.715 ms (2 allocations: 11.44 MiB) # before (PR #482)
  31.418 ms (2 allocations: 11.44 MiB) # after

julia> @btime convert.(RGB{N0f8}, $xyz_f32);
  42.136 ms (2 allocations: 2.86 MiB) # before (PR #482)
  40.123 ms (2 allocations: 2.86 MiB) # after

@kimikage
Copy link
Collaborator Author

The connection between the curve and the line in fxyz2lab exactly matches in value and slope. Therefore, it is possible to merge the two with min. On the other hand, in srgb_compand there is a small gap between the curve and the line.

julia> Float64(big"0.0031308"^(5/big"12") * big"1.055" - big"0.055")
0.04044990748269015

julia> Float64(big"0.0031308" * big"12.92") # != 0.04045
0.040449936

@kimikage kimikage marked this pull request as ready for review June 23, 2021 02:56
@kimikage kimikage merged commit bf61512 into JuliaGraphics:master Jun 23, 2021
@kimikage kimikage deleted the pow5_12_float32 branch June 23, 2021 15:21
kimikage added a commit to kimikage/Colors.jl that referenced this pull request May 11, 2024
kimikage added a commit that referenced this pull request May 11, 2024
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