Commit 645ff6c7 authored by Mark Oteiza's avatar Mark Oteiza

Add CAM02 JCh and CAM02-UCS J'a'b' conversions

* src/lcms.c (rad2deg, parse_jch_list, parse_jab_list, xyz_to_jch):
(jch_to_xyz, jch_to_jab, jab_to_jch): New functions.
(lcms-jch->xyz, lcms-jch->xyz, lcms-jch->jab, lcms-jab->jch): New Lisp
functions.
(lcms-cam02-ucs): Refactor.
(syms_of_lcms2): Declare new functions.
* test/src/lcms-tests.el (lcms-roundtrip, lcms-ciecam02-gold):
(lcms-jmh->cam02-ucs-silver): New tests.
* etc/NEWS: Mention new functions.
parent 157007b5
......@@ -76,7 +76,8 @@ If the lcms2 library is installed, Emacs will enable features built on
top of that library. The new configure option '--without-lcms2' can
be used to build without lcms2 support even if it is installed. Emacs
linked to Little CMS exposes color management functions in Lisp: the
color metrics 'lcms-cie-de2000' and 'lcms-cam02-ucs'.
color metrics 'lcms-cie-de2000' and 'lcms-cam02-ucs', as well as
functions for conversion to and from CIE CAM02 and CAM02-UCS.
** The configure option '--with-gameuser' now defaults to 'no',
as this appears to be the most common configuration in practice.
......
This diff is collapsed.
......@@ -94,6 +94,38 @@ B is considered the exact value."
(apply #'color-xyz-to-xyy (lcms-temp->white-point 7504))
'(0.29902 0.31485 1.0))))
(ert-deftest lcms-roundtrip ()
"Test accuracy of converting to and from different color spaces"
(skip-unless (featurep 'lcms2))
(should
(let ((color '(.5 .3 .7)))
(lcms-triple-approx-p (lcms-jch->xyz (lcms-xyz->jch color))
color
0.0001)))
(should
(let ((color '(.8 -.2 .2)))
(lcms-triple-approx-p (lcms-jch->jab (lcms-jab->jch color))
color
0.0001))))
(ert-deftest lcms-ciecam02-gold ()
"Test CIE CAM02 JCh gold values"
(skip-unless (featurep 'lcms2))
(should
(lcms-triple-approx-p
(lcms-xyz->jch '(0.1931 0.2393 0.1014)
'(0.9888 0.900 0.3203)
'(18 200 1 1.0))
'(48.0314 38.7789 191.0452)
0.02))
(should
(lcms-triple-approx-p
(lcms-xyz->jch '(0.1931 0.2393 0.1014)
'(0.9888 0.90 0.3203)
'(18 20 1 1.0))
'(47.6856 36.0527 185.3445)
0.09)))
(ert-deftest lcms-dE-cam02-ucs-silver ()
"Test CRI-CAM02-UCS deltaE metric values from colorspacious."
(skip-unless (featurep 'lcms2))
......@@ -114,4 +146,16 @@ B is considered the exact value."
8.503323264883667
0.04)))
(ert-deftest lcms-jmh->cam02-ucs-silver ()
"Compare JCh conversion to CAM02-UCS to values from colorspacious."
(skip-unless (featurep 'lcms2))
(should
(lcms-triple-approx-p (lcms-jch->jab '(50 20 10))
'(62.96296296 16.22742674 2.86133316)
0.05))
(should
(lcms-triple-approx-p (lcms-jch->jab '(10 60 100))
'(15.88785047 -6.56546789 37.23461867)
0.04)))
;;; lcms-tests.el ends here
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment