@@ -45,6 +45,34 @@ def test_generate_reference_colour_checker(self):
4545 result = common .generate_reference_colour_checker ()
4646 self .assertTrue (np .allclose (expected , result , atol = 1e-20 ))
4747
48+ def test_calculate_camera_npm_and_primaries_wp (self ):
49+ """Test generating a camera npm from an RGB to AP0 matrix"""
50+ input_matrix = [
51+ [0.785043 , 0.083844 , 0.131118 ],
52+ [0.023172 , 1.087892 , - 0.111055 ],
53+ [- 0.073769 , - 0.314639 , 1.388537 ],
54+ ]
55+
56+ npm , primaries , wp = common .calculate_camera_npm_and_primaries_wp (input_matrix )
57+
58+ expected_npm = [
59+ [0.7353579 , 0.06867992 , 0.14646275 ],
60+ [0.28673187 , 0.84296573 , - 0.1297009 ],
61+ [- 0.07965591 , - 0.34720223 , 1.5155319 ],
62+ ]
63+
64+ expected_primaries = [
65+ [0.7802753326723714 , 0.3042461485259778 ],
66+ [0.1216772523298739 , 1.4934459215643787 ],
67+ [0.09558399073520502 , - 0.08464493023427101 ],
68+ ]
69+
70+ expected_wp = [0.31274994 , 0.32903601 ]
71+
72+ self .assertTrue (np .allclose (expected_npm , npm , atol = 1e-6 ))
73+ self .assertTrue (np .allclose (expected_primaries , primaries , atol = 1e-6 ))
74+ self .assertTrue (np .allclose (expected_wp , wp , atol = 1e-6 ))
75+
4876
4977class TestExposureClippingMask (TestIDTBase ):
5078 """
0 commit comments