Function: color-xyz-to-lab

color-xyz-to-lab is a byte-compiled function defined in color.el.gz.

Signature

(color-xyz-to-lab X Y Z &optional WHITE-POINT)

Documentation

Convert CIE XYZ to CIE L*a*b*.

WHITE-POINT specifies the (X Y Z) white point for the conversion. If omitted or nil, use color-d65-xyz.

Source Code

;; Defined in /usr/src/emacs/lisp/color.el.gz
(defun color-xyz-to-lab (X Y Z &optional white-point)
  "Convert CIE XYZ to CIE L*a*b*.
WHITE-POINT specifies the (X Y Z) white point for the
conversion.  If omitted or nil, use `color-d65-xyz'."
  (pcase-let* ((`(,Xr ,Yr ,Zr) (or white-point color-d65-xyz))
               (xr (/ X Xr))
             (yr (/ Y Yr))
             (zr (/ Z Zr))
             (fx (if (> xr color-cie-ε)
                     (expt xr (/ 3.0))
                   (/ (+ (* color-cie-κ xr) 16) 116.0)))
             (fy (if (> yr color-cie-ε)
                     (expt yr (/ 3.0))
                   (/ (+ (* color-cie-κ yr) 16) 116.0)))
             (fz (if (> zr color-cie-ε)
                     (expt zr (/ 3.0))
                   (/ (+ (* color-cie-κ zr) 16) 116.0))))
        (list
         (- (* 116 fy) 16)                  ; L
         (* 500 (- fx fy))                  ; a
     (* 200 (- fy fz)))))             ; b