X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fcolour_conversion_test.cc;h=b743497bfc27bcd9f7bc3b5666464322b6e71236;hb=08f1afc562c2f5efeca88371cc4e7ced3b2f36a2;hp=2eb5edf561648b3cbe8a153daf0de7941053cf94;hpb=86bfdeb77f55b379302a65b22f57fc0583ec6b3c;p=libdcp.git diff --git a/test/colour_conversion_test.cc b/test/colour_conversion_test.cc index 2eb5edf5..b743497b 100644 --- a/test/colour_conversion_test.cc +++ b/test/colour_conversion_test.cc @@ -54,6 +54,7 @@ check_modified_gamma (shared_ptr tf, int bit_depth, bool } } +/** Check that the gamma correction LUTs are right for sRGB */ BOOST_AUTO_TEST_CASE (colour_conversion_test1) { ColourConversion cc = ColourConversion::srgb_to_xyz (); @@ -67,6 +68,7 @@ BOOST_AUTO_TEST_CASE (colour_conversion_test1) check_gamma (cc.out(), 16, true, 1 / 2.6); } +/** Check that the gamma correction LUTs are right for REC709 */ BOOST_AUTO_TEST_CASE (colour_conversion_test2) { ColourConversion cc = ColourConversion::rec709_to_xyz (); @@ -80,3 +82,23 @@ BOOST_AUTO_TEST_CASE (colour_conversion_test2) check_gamma (cc.out(), 16, true, 1 / 2.6); } +/** Check that the xyz_to_rgb matrix is the inverse of the rgb_to_xyz one */ +BOOST_AUTO_TEST_CASE (colour_conversion_matrix_test) +{ + ColourConversion c = ColourConversion::srgb_to_xyz (); + + boost::numeric::ublas::matrix A = c.rgb_to_xyz (); + boost::numeric::ublas::matrix B = c.xyz_to_rgb (); + + BOOST_CHECK_CLOSE (A(0, 0) * B(0, 0) + A(0, 1) * B(1, 0) + A(0, 2) * B(2, 0), 1, 0.1); + BOOST_CHECK (fabs (A(0, 0) * B(0, 1) + A(0, 1) * B(1, 1) + A(0, 2) * B(2, 1)) < 1e-6); + BOOST_CHECK (fabs (A(0, 0) * B(0, 2) + A(0, 1) * B(1, 2) + A(0, 2) * B(2, 2)) < 1e-6); + + BOOST_CHECK (fabs (A(1, 0) * B(0, 0) + A(1, 1) * B(1, 0) + A(1, 2) * B(2, 0)) < 1e-6); + BOOST_CHECK_CLOSE (A(1, 0) * B(0, 1) + A(1, 1) * B(1, 1) + A(1, 2) * B(2, 1), 1, 0.1); + BOOST_CHECK (fabs (A(1, 0) * B(0, 2) + A(1, 1) * B(1, 2) + A(1, 2) * B(2, 2)) < 1e-6); + + BOOST_CHECK (fabs (A(2, 0) * B(0, 0) + A(2, 1) * B(1, 0) + A(2, 2) * B(2, 0)) < 1e-6); + 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); +}