Closed ehlertij closed 2 years ago
Looks good.
I need to look at the current status of the Color project before I merge this, but I expect to merge this soon.
Having written an implementation of this myself, I was curious if the new one tests out okay. It does! It passed the tests I had written for my own.
I have unmerged changes, largely dealing with putting Lab into its own class and contrast routines . LMK if interested in a merge request for those.
@daveheitzman, I am definitely interested in getting this sorted out and don’t see the time to do so in the near future. There’s several PRs that are implementing similar things that I haven’t had time to examine.
Sorry, I realized I didn’t answer your question (@daveheitzman): yes, I want that PR, but it may take a bit of time to get it reviewed by me. You’re a collaborator, so if you want to look at merging this in with an eye toward this work and other work you’ve got for open PRs becoming Color 2.0, that would be best IMO.
Thanks much @halostatue and @daveheitzman!
This implements the newer CIEDE2000 color difference algorithm for use with
Color::RGB.closest_match
. The Wikipedia article on Color Difference outlines the benefits of this algorithm over the older CIE94 version. The main benefit is that it compensates for some inconsistencies in the blue region.To implement this I used the implementation steps from this research document, and I matched all the lines back to the numbers outlined in the document. This should, hopefully, make it a little easier to follow.
I do not claim to be an expert on color theory, but I'm fairly confident that I implemented this algorithm correctly. I've done a lot of manual testing as well as automated testing, and so far it is surpasses or is comparable to the CIE94 version in all respects.
Again, the main benefit of this the blue region. Color set that I found particularly bad with the CIE94 version is very dark blues that appear black, but were mapping to a Midnight Blue color instead. This version of the algorithm fixes the problem. Here's an example:
This color (#29212C):
When given these two colors to find as its closest match: Black (#000000):
MidnightBlue (#191970):
With the CIE94 algorithm it matches to MidnightBlue. With the CIEDE2000 algorithm it matches to Black instead (which is visually correct).
I also had to update the test that was matching Firebrick to Crimson when given the choice between Crimson and DarkRed. The CIEDE2000 algorithm matches it to DarkRed instead of Crimson, which, in my opinion at least, is a very slightly closer visual match.
Firebrick:
DarkRed:
Crimson: