Subject: Re: bug#28400: 26.0.50; lcms2 bindings

From: Mark Oteiza <[email-masked]>
Date: Sun, 10 Sep 2017 18:04:22 -0400

On 09/09/17 at 08:37pm, Eli Zaretskii wrote:
>> From: Mark Oteiza <[email-masked]>
>> Date: Sat, 09 Sep 2017 11:50:34 -0400
>>
>> Some time ago I wrote some integration with lcms2 in the interest of
>> replacing tty-color-approximate, color-distance, etc. with superior
>> (more perceptually uniform) color metrics.  This would presumably
>> improve Emacs' color picking on smaller color palettes (e.g. 256 color
>> term) and potentially provide access to many useful color-related
>> functions in Lisp---not to discount color.el.
>
>Is it really so much better than what we have now to justify requiring
>yet another library to build Emacs?  If it is, could you tell what are
>the main advantages, or point to where those advantages are described?

It was just much easier for me to hack existing code than figure out adding
a new file and the configure.ac business.  It would be much more
sensible to offer it as an optional feature and expose color metrics as
optional arguments, e.g.

  (color-distance COLOR1 COLOR2 &optional FRAME METRIC)

where METRIC accepts two colors and returns a number.

>Btw, 256 colors is not "small" by Emacs standards, because our color
>approximation should (and does) work in 8-color terminals as well.

Yes, I should have used a different word than "small".  Approximations
for smaller palettes is easier because the differences between
individual members of the palette are much bigger.  The 256 color
palette (and larger) has many colors much closer to one another, and
calculating perceptual differences between colors that are close
requires a more sophisticated model.

For instance, take CIEDE2000
https://en.wikipedia.org/wiki/Color_difference#CIEDE2000
and compare it to the newer CAM02-UCS
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.844.5693&rep=rep1&type=pdf
IIRC CAM02 is the de facto model for CMS.  I'm certain Windows uses it
for its CMS.

I like this talk about Matplotlib's new color map.  It explains the
differences between color spaces among other things
https://www.youtube.com/watch?v=xAoljeRJ3lU