17
$\begingroup$

Is the function ColorDistance symmetric, i.e. is it always true that ColorDistance[a,b] == ColorDistance[b,a], as use of the word distance would suggest?

$\endgroup$
18
$\begingroup$

It depends on the DistanceFunction used.

"CIE76" and "CIE2000" are symmetric. However, "CIE94" and "CMC" are not.

ColorDistance[##, DistanceFunction -> "CIE76"] & @@@ {{Red, Blue}, {Blue, Red}}
(* {1.8401283, 1.8401283} *)

ColorDistance[##, DistanceFunction -> "CIE94"] & @@@ {{Red, Blue}, {Blue, Red}}
(* {0.73824131, 0.65806887} *)

ColorDistance[##, DistanceFunction -> "CIE2000"] & @@@ {{Red, Blue}, {Blue, Red}}
(* {0.55797554, 0.55797554} *)

ColorDistance[##, DistanceFunction -> "CMC"] & @@@ {{Red, Blue}, {Blue, Red}}
(* {1.1576119, 0.8386259} *)

Many applications that use some sort of distance function, such as clustering, assume the distance function to be symmetric. It is important to use a symmetric colour distance for these. FindClusters uses ColorDistance for colours by default. The default DistanceFunction for ColorDistance is the symmetric "CIE76".

$\endgroup$
  • 1
    $\begingroup$ I've worked with color before and I am still surprised by this. I should probably look into this myself but I'm feeling lazy; why are some of these functions asymmetric? $\endgroup$ – Mr.Wizard Jun 24 '15 at 13:15
  • 1
    $\begingroup$ @Mr.Wizard "Because they're defined that way." Well, why they are defined that way? I don't know the answer to that, but if we look at the definition of, say, CIE94 distance function, it's apparent that $S_C$ and $S_H$ depend only on one color, not both. $\endgroup$ – kirma Jun 24 '15 at 13:18
  • 6
    $\begingroup$ BTW, if you want to lose a bit more faith on color distance functions, please read ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf (The CIEDE2000 Color-Difference Formula: Implementation Notes, Supplementary Test Data, and Mathematical Observations), especially the part on discontinuities. "[...] the discontinuities do preclude the use of the formula in analysis based on Taylor series approximations and in design techniques using gradient based optimization, that not only require continuity of the function but also continuity of the first derivative." $\endgroup$ – kirma Jun 24 '15 at 14:06
  • 2
    $\begingroup$ @Mr.Wizard One reason is because it makes the functions less complex — they can apply whatever corrections they need based on one color, instead of at some kind of midpoint between two colors. My understanding is also that the asymmetrical ones are used for measuring the impact of a small area of color B on a large background of color A, where the assymetry might actually be appropriate, assuming that the visual system mostly accommodates to A. $\endgroup$ – hobbs Jun 24 '15 at 18:31
  • 2
    $\begingroup$ @MrWizard I asked someone who researches perception and I was told that these measures are not particularly meaningful for large distances. They're meant for comparing colours that are relatively close. In this case the asymmetry is much less pronounced. $\endgroup$ – Szabolcs Jun 25 '15 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.