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

CMC distance is weird #45

Closed
jmw86069 opened this issue Apr 24, 2024 · 1 comment
Closed

CMC distance is weird #45

jmw86069 opened this issue Apr 24, 2024 · 1 comment

Comments

@jmw86069
Copy link

While testing the different distance metrics... I think the "CMC" implementation may have a problem.
(This not so urgent to me, the other metrics seem fairly good. But this CMC method seems incorrect, unless I'm doing something wrong.)

Test case is to calculate distance between a blue "#007FFF" hex color, versus all R colors(), then sort for lowest distance.
The color with lowest CMC distance is darkorange3.
Fwiw the test works well with other distance metrics.
I tested a bunch of colors, across all metrics, etc. CMC results consistently resemble an artistic mosaic of random colors. (I mean, that might also be useful, but for different reasons!)

Here is the test case:

ref_colors <- colors();
names(ref_colors) <- ref_colors
fdists <- farver::compare_colour(farver::decode_colour("#007FFF", to="lch"),
   farver::decode_colour(ref_colors, to="lch"),
   method="cmc",
   to_space="lch",
   from_space="lch")[1, ]
head(fdists[order(fdists)])

Output:

    darkorange3      violetred2    mediumorchid   mediumorchid3 mediumslateblue      royalblue1 
          0.482           0.542           0.686           1.078           1.476           1.573

Quick plot of the first 6 colors (the first point is the input blue, the next 6 are colors with lowest CMC distance):

plot(x=1:7,
   y=c(0, head(fdists[order(fdists)])),
   pch=20, cex=5, col=c("#007FFF", head(ref_colors[order(fdists)])))
image

Best I could do is find an online calculator to confirm that these two colors are not similar (they are not):
http://colormine.org/delta-e-calculator/cmc

I don't think this is the bug from #21, but I did not look in detail.

@thomasp85
Copy link
Owner

When I created farmer I took the color comparison implementations at face value from the library I used. Looking at it now I can see that it is pretty bad 😬

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

No branches or pull requests

2 participants