# Conversion netween CIELAB D50 2° values and ACEScg

Is there any tool to convert CIELAB values to ACEScg values? If not, I can write a C++ program to do so. Currently, I have a program that converts CIELAB values to linear sRGB values, but I’m not sure how to convert them to ACEScg values.

The ACES Github page (aces-dev/README-MATRIX.md at master · ampas/aces-dev · GitHub) provides a matrix to convert from XYZ to AP1, which is:

``````1.6410233797, -0.3248032942, -0.2364246952,
-0.6636628587,  1.6153315917,  0.0167563477,
0.0117218943, -0.0082844420,  0.9883948585
``````

However, I’m not sure if this is the correct matrix to use, and I don’t know whether I should use XYZ D50, D60, or D65 values as input.

Hi @tommyhhrip,

You could use Colour:

``````import colour
import numpy as np

LAB = np.array([50, 10, -40])
WP_LAB = colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D50"]
RGB_COLOURSPACE = colour.models.RGB_COLOURSPACE_ACESCG

XYZ = colour.Lab_to_XYZ(LAB, WP_LAB)
RGB = colour.XYZ_to_RGB(XYZ, RGB_COLOURSPACE, WP_LAB)
print(RGB)
``````
``````[ 0.16645398  0.17553745  0.45316944]
``````
``````colour.convert(
LAB / 100, "CIE Lab", "RGB",
Lab_to_XYZ={"illuminant": WP_LAB},
XYZ_to_RGB={"colourspace": RGB_COLOURSPACE, "illuminant": WP_LAB})
``````
``````[ 0.16645398  0.17553745  0.45316944]
``````
``````colour.convert(
LAB / 100, "CIE Lab", "RGB",
Lab_to_XYZ={"illuminant": WP_LAB},
XYZ_to_RGB={"colourspace": RGB_COLOURSPACE, "illuminant": WP_LAB},
verbose={"mode": "Long"})
``````
``````===============================================================================
*                                                                             *
*   [ Conversion Path ]                                                       *
*                                                                             *
*   "Lab_to_XYZ" --> "XYZ_to_RGB"                                             *
*                                                                             *
===============================================================================
===============================================================================
*                                                                             *
*   [ "Lab_to_XYZ" ]                                                          *
*                                                                             *
*   [ Signature ]                                                             *
*                                                                             *
*   <Signature (Lab: 'ArrayLike', illuminant: 'ArrayLike' = array([ 0.3127,   *
*   0.329 ])) -> 'NDArrayFloat'>                                              *
*                                                                             *
*   [ Filtered Arguments ]                                                    *
*                                                                             *
*   {'illuminant': array([ 0.3457,  0.3585])}                                 *
*                                                                             *
*   [ Conversion Output ]                                                     *
*                                                                             *
*   [ 0.19700617  0.18418652  0.3751713 ]                                     *
*                                                                             *
===============================================================================
===============================================================================
*                                                                             *
*   [ "XYZ_to_RGB" ]                                                          *
*                                                                             *
*   [ Signature ]                                                             *
*                                                                             *
*   <Signature (XYZ: 'ArrayLike', colourspace: 'RGB_Colourspace | str',       *
*   illuminant: 'ArrayLike | None' = None, chromatic_adaptation_transform:    *
*   "Literal['Bianco 2010', 'Bianco PC 2010', 'Bradford', 'CAT02 Brill        *
*   2008', 'CAT02', 'CAT16', 'CMCCAT2000', 'CMCCAT97', 'Fairchild',           *
*   'Sharp', 'Von Kries', 'XYZ Scaling'] | str | None" = 'CAT02',             *
*   apply_cctf_encoding: 'bool' = False, *args: 'Any', **kwargs: 'Any') ->    *
*   'NDArrayFloat'>                                                           *
*                                                                             *
*   [ Filtered Arguments ]                                                    *
*                                                                             *
*   {'colourspace': RGB_Colourspace('ACEScg',                                 *
*                   [[ 0.713,  0.293],                                        *
*                    [ 0.165,  0.83 ],                                        *
*                    [ 0.128,  0.044]],                                       *
*                   [ 0.32168,  0.33767],                                     *
*                   'ACES',                                                   *
*                   [[ 0.66245418,  0.13400421,  0.15618769],                 *
*                    [ 0.27222872,  0.67408177,  0.05368952],                 *
*                    [-0.00557465,  0.00406073,  1.0103391 ]],                *
*                   [[ 1.64102338, -0.32480329, -0.2364247 ],                 *
*                    [-0.66366286,  1.61533159,  0.01675635],                 *
*                    [ 0.01172189, -0.00828444,  0.98839486]],                *
*                   linear_function,                                          *
*                   linear_function,                                          *
*                   False,                                                    *
*                   False),                                                   *
*    'illuminant': array([ 0.3457,  0.3585])}                                 *
*                                                                             *
*   [ Conversion Output ]                                                     *
*                                                                             *
*   [ 0.16645398  0.17553745  0.45316944]                                     *
*                                                                             *
===============================================================================
array([ 0.16645398,  0.17553745,  0.45316944])
``````

You can also use it online with Google Colab so that you don’t need to install anything. Here is a notebook: Google Colab

Cheers,

Thomas