- float white_x, white_y, white_z, l_scale_white, m_scale_white, s_scale_white;
- convert_color_temperature_to_xyz(output_color_temperature, &white_x, &white_y, &white_z);
- compute_lms_scaling_factors(white_x, white_y, white_z, &l_scale_white, &m_scale_white, &s_scale_white);
-
- float ref_x, ref_y, ref_z, l_scale_ref, m_scale_ref, s_scale_ref;
- convert_color_temperature_to_xyz(6500.0f, &ref_x, &ref_y, &ref_z);
- compute_lms_scaling_factors(ref_x, ref_y, ref_z, &l_scale_ref, &m_scale_ref, &s_scale_ref);
-
- l_scale *= l_scale_ref / l_scale_white;
- m_scale *= m_scale_ref / m_scale_white;
- s_scale *= s_scale_ref / s_scale_white;
+ Vector3d white_xyz = convert_color_temperature_to_xyz(output_color_temperature);
+ Vector3d lms_scale_white = compute_lms_scaling_factors(white_xyz);
+
+ Vector3d ref_xyz = convert_color_temperature_to_xyz(6500.0f);
+ Vector3d lms_scale_ref = compute_lms_scaling_factors(ref_xyz);
+
+ lms_scale[0] *= lms_scale_ref[0] / lms_scale_white[0];
+ lms_scale[1] *= lms_scale_ref[1] / lms_scale_white[1];
+ lms_scale[2] *= lms_scale_ref[2] / lms_scale_white[2];