summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-05 19:04:37 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-05 19:04:37 +0100
commit6f21c193a01b96e289a03b08ee00f57269b9ff86 (patch)
tree8f4106505f9ef08734daa919bc3fe4985453551f /test
parent0fb6983c70d6fe201768040563752cb75889197a (diff)
Add test for Bradford matrix calculation.
Diffstat (limited to 'test')
-rw-r--r--test/colour_conversion_test.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/colour_conversion_test.cc b/test/colour_conversion_test.cc
index b963217d..d9bf2e77 100644
--- a/test/colour_conversion_test.cc
+++ b/test/colour_conversion_test.cc
@@ -102,3 +102,41 @@ BOOST_AUTO_TEST_CASE (colour_conversion_matrix_test)
BOOST_CHECK (fabs (A(2, 0) * B(0, 1) + A(2, 1) * B(1, 1) + A(2, 2) * B(2, 1)) < 1e-6);
BOOST_CHECK_CLOSE (A(2, 0) * B(0, 2) + A(2, 1) * B(1, 2) + A(2, 2) * B(2, 2), 1, 0.1);
}
+
+BOOST_AUTO_TEST_CASE (colour_conversion_bradford_test)
+{
+ ColourConversion c = ColourConversion::srgb_to_xyz ();
+
+ /* CIE "A" illuminant from http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
+ un-normalised using a factor k where k = 1 / (1 + x + z)
+ */
+ c.set_adjusted_white (Chromaticity (0.447576324, 0.407443172));
+
+ boost::numeric::ublas::matrix<double> b = c.bradford ();
+
+ /* Check the conversion matrix against the one quoted on brucelindbloom.com */
+ BOOST_CHECK_CLOSE (b(0, 0), 1.2164557, 0.1);
+ BOOST_CHECK_CLOSE (b(0, 1), 0.1109905, 0.1);
+ BOOST_CHECK_CLOSE (b(0, 2), -0.1549325, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 0), 0.1533326, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 1), 0.9152313, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 2), -0.0559953, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 0), -0.0239469, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 1), 0.0358984, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 2), 0.3147529, 0.1);
+
+ /* Same for CIE "B" illuminant */
+ c.set_adjusted_white (Chromaticity (0.99072 * 0.351747305, 0.351747305));
+
+ b = c.bradford ();
+
+ BOOST_CHECK_CLOSE (b(0, 0), 1.0641402, 0.1);
+ BOOST_CHECK_CLOSE (b(0, 1), 0.0325780, 0.1);
+ BOOST_CHECK_CLOSE (b(0, 2), -0.0489436, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 0), 0.0446103, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 1), 0.9766379, 0.1);
+ BOOST_CHECK_CLOSE (b(1, 2), -0.0174854, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 0), -0.0078485, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 1), 0.0119945, 0.1);
+ BOOST_CHECK_CLOSE (b(2, 2), 0.7785377, 0.1);
+}