[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Doc string and operation of color-distance
From: |
Mark Oteiza |
Subject: |
Re: Doc string and operation of color-distance |
Date: |
Fri, 15 Sep 2017 11:15:59 -0400 |
User-agent: |
Mutt/1.9.0 (2017-09-02) |
On 15/09/17 at 04:40pm, Eli Zaretskii wrote:
> > From: Mark Oteiza <address@hidden>
> > Date: Thu, 14 Sep 2017 15:43:28 -0400
> > Cc: address@hidden
> >
> > At the very least we should feed metrics the translated RGBs.
>
> Yes. But it would be nicer if the lcms.c functions accepted colors in
> any form supported by Emacs: a color name, a string RGB spec, or a
> list of RGB values. I think.
>
> > Beyond that, in order to use (for example) lcms2-cam02-ucs with
> > color-distance, one has to translate RGB to XYZ, so the metric would be
> >
> > (lambda (a b)
> > (lcms2-cam02-ucs (color-srgb-to-xyz a) (color-srgb-to-xyz b))
>
> color-srgb-to-xyz accepts 3 arguments, not one. Also, its doc string
> says the components are floats between 0 and 1. So this should be
> amended accordingly.
Ah, yes I forget about color.el's calling conventions…
(defun lcms-rgb16->rgb1 (color)
(mapcar (lambda (x) (/ (lsh x -8) 255.0)) color))
(lambda (a b)
(lcms-cam02-ucs (apply #'color-srgb-to-xyz (color-rgb16b->rgb1 a))
(apply #'color-srgb-to-xyz (color-rgb16b->rgb1 b))))