Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
749 stars 60 forks source link

Add traits for delta E and the improved formulas from Huang et al #355

Closed Ogeon closed 12 months ago

Ogeon commented 12 months ago

Adds the DeltaE, ImprovedDeltaE and ImprovedCiede200 traits. The first one represents the "default" or canonical delta E formula for a color space as it was originally specified. If there is no specification for delta E, it's not implemented. It's also not necessarily the best. The other two implement the enhancements described in Power functions improving the performance of color-difference formulas by Huang et al. They are provided as separate traits so the user can choose which one is the most appropriate for their use case.

This is the result of me trying to sort out where different formulas come from and prepare for adding a delta E for CAM16-UCS in #342. The recommended formula for CAM16 turns out to be the "improved" one.

codecov[bot] commented 12 months ago

Codecov Report

Merging #355 (c0f13d8) into master (bae6ab5) will increase coverage by 0.11%. Report is 2 commits behind head on master. The diff coverage is 91.89%.

@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage   78.00%   78.11%   +0.11%     
==========================================
  Files         115      115              
  Lines       19738    19812      +74     
  Branches    19738    19812      +74     
==========================================
+ Hits        15396    15476      +80     
+ Misses       4076     4070       -6     
  Partials      266      266              
Files Changed Coverage Ξ”
palette/src/color_difference.rs 94.17% <0.00%> (+0.17%) :arrow_up:
palette/src/lab.rs 86.54% <100.00%> (+0.45%) :arrow_up:
palette/src/lch.rs 82.72% <100.00%> (+4.21%) :arrow_up:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codspeed-hq[bot] commented 12 months ago

CodSpeed Performance Report

Merging #355 will not alter performance

Comparing improved_delta_e (c0f13d8) with master (bae6ab5)

Summary

βœ… 40 untouched benchmarks

πŸ†• 5 new benchmarks

Benchmarks breakdown

Benchmark master improved_delta_e Change
πŸ†• Lch CIEDE2000 N/A 34 ms N/A
πŸ†• Lab delta E N/A 755.1 Β΅s N/A
πŸ†• Lch delta E N/A 3.5 ms N/A
πŸ†• Lch delta E via Lab N/A 3.5 ms N/A
πŸ†• Lab CIEDE2000 N/A 33.5 ms N/A
Ogeon commented 12 months ago

Ok, this is a pickle. The memchr dependency is only used in tests, so the dependency shouldn't matter for MSRV. Yet, I can't run the full tests without it. I'll see if I can re-shuffle the tests for now.

Ogeon commented 12 months ago

Interesting, those benchmarks run about 10 to 20 times faster on my machine. Either way, it's the relative difference that's actually interesting.

Ogeon commented 12 months ago

bors r+

bors[bot] commented 12 months ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.