# colour_hdri.models Package

## Sub-Packages

- colour_hdri.models.dataset Package
  - Sub-Modules
    - colour_hdri.models.dataset.dng Module
      - Adobe DNG SDK Dataset
  - Module Contents

## Sub-Modules

- colour_hdri.models.dng Module
  - Adobe DNG SDK Colour Processing
- colour_hdri.models.rgb Module
  - RGB Colourspace & Transformations

## Module Contents

`colour_hdri.models.``xy_to_camera_neutral`(xy, CCT_calibration_illuminant_1, CCT_calibration_illuminant_2, M_color_matrix_1, M_color_matrix_2, M_camera_calibration_1, M_camera_calibration_2, analog_balance)

  Converts given xy white balance chromaticity coordinates to Camera Neutral coordinates.

  Parameters: | xy (array_like) – xy white balance chromaticity coordinates. CCT_calibration_illuminant_1 (numeric) – Correlated colour temperature of CalibrationIlluminant1. CCT_calibration_illuminant_2 (numeric) – Correlated colour temperature of CalibrationIlluminant2. M_color_matrix_1 (array_like) – ColorMatrix1 tag matrix. M_color_matrix_2 (array_like) – ColorMatrix2 tag matrix. M_camera_calibration_1 (array_like) – CameraCalibration1 tag matrix. M_camera_calibration_2 (array_like) – CameraCalibration2 tag matrix. analog_balance (array_like) – AnalogBalance tag vector.
  Returns: | Camera Neutral coordinates.
  Return type: | ndarray

  References

  [4] | Adobe Systems. (2012). Translating White Balance xy Coordinates to Camera Neutral Coordinates. In Digital Negative (DNG) Specification (p. 80).

  Examples

      >>> M_color_matrix_1 = np.array([
      ...     [0.5309, -0.0229, -0.0336],
      ...     [-0.6241, 1.3265, 0.3337],
      ...     [-0.0817, 0.1215, 0.6664]])
      >>> M_color_matrix_2 = np.array([
      ...     [0.4716, 0.0603, -0.0830],
      ...     [-0.7798, 1.5474, 0.2480],
      ...     [-0.1496, 0.1937, 0.6651]])
      >>> M_camera_calibration_1 = np.identity(3)
      >>> M_camera_calibration_2 = np.identity(3)
      >>> analog_balance = np.ones(3)
      >>> xy_to_camera_neutral(
      ...     np.array([0.32816244, 0.34698169]),
      ...     2850,
      ...     6500,
      ...     M_color_matrix_1,
      ...     M_color_matrix_2,
      ...     M_camera_calibration_1,
      ...     M_camera_calibration_2,
      ...     analog_balance)
      array([ 0.4130699...,  1...        ,  0.646465...])

`colour_hdri.models.``camera_neutral_to_xy`(camera_neutral, CCT_calibration_illuminant_1, CCT_calibration_illuminant_2, M_color_matrix_1, M_color_matrix_2, M_camera_calibration_1, M_camera_calibration_2, analog_balance, epsilon=<Mock name='mock.EPSILON' id='4496273360'>)

  Converts given Camera Neutral coordinates to xy white balance chromaticity coordinates.

  Parameters: | camera_neutral (array_like) – Camera Neutral coordinates. CCT_calibration_illuminant_1 (numeric) – Correlated colour temperature of CalibrationIlluminant1. CCT_calibration_illuminant_2 (numeric) – Correlated colour temperature of CalibrationIlluminant2. M_color_matrix_1 (array_like) – ColorMatrix1 tag matrix. M_color_matrix_2 (array_like) – ColorMatrix2 tag matrix. M_camera_calibration_1 (array_like) – CameraCalibration1 tag matrix. M_camera_calibration_2 (array_like) – CameraCalibration2 tag matrix. analog_balance (array_like) – AnalogBalance tag vector. epsilon (numeric, optional) – Threshold value for computation convergence.
  Returns: | xy white balance chromaticity coordinates.
  Return type: | ndarray
  Raises: | `RuntimeError` – If the given Camera Neutral coordinates did not converge to xy white balance chromaticity coordinates.

  References

  [5] | Adobe Systems. (2012). Translating Camera Neutral Coordinates to White Balance xy Coordinates. In Digital Negative (DNG) Specification (pp. 80–81).

  Examples

      >>> M_color_matrix_1 = np.array([
      ...     [0.5309, -0.0229, -0.0336],
      ...     [-0.6241, 1.3265, 0.3337],
      ...     [-0.0817, 0.1215, 0.6664]])
      >>> M_color_matrix_2 = np.array([
      ...     [0.4716, 0.0603, -0.0830],
      ...     [-0.7798, 1.5474, 0.2480],
      ...     [-0.1496, 0.1937, 0.6651]])
      >>> M_camera_calibration_1 = np.identity(3)
      >>> M_camera_calibration_2 = np.identity(3)
      >>> analog_balance = np.ones(3)
      >>> camera_neutral_to_xy(
      ...     np.array([0.413070, 1.000000, 0.646465]),
      ...     2850,
      ...     6500,
      ...     M_color_matrix_1,
      ...     M_color_matrix_2,
      ...     M_camera_calibration_1,
      ...     M_camera_calibration_2,
      ...     analog_balance)
      array([ 0.3281624...,  0.3469816...])

`colour_hdri.models.``XYZ_to_camera_space_matrix`(xy, CCT_calibration_illuminant_1, CCT_calibration_illuminant_2, M_color_matrix_1, M_color_matrix_2, M_camera_calibration_1, M_camera_calibration_2, analog_balance)

  Returns the CIE XYZ to Camera Space matrix for given xy white balance chromaticity coordinates. [4]

  Parameters: | xy (array_like) – xy white balance chromaticity coordinates. CCT_calibration_illuminant_1 (numeric) – Correlated colour temperature of CalibrationIlluminant1. CCT_calibration_illuminant_2 (numeric) – Correlated colour temperature of CalibrationIlluminant2. M_color_matrix_1 (array_like) – ColorMatrix1 tag matrix. M_color_matrix_2 (array_like) – ColorMatrix2 tag matrix. M_camera_calibration_1 (array_like) – CameraCalibration1 tag matrix. M_camera_calibration_2 (array_like) – CameraCalibration2 tag matrix. analog_balance (array_like) – AnalogBalance tag vector.
  Returns: | CIE XYZ to Camera Space matrix.
  Return type: | ndarray

  Notes

  - The reference illuminant is D50 as defined per `ADOBE_DNG_XYZ_ILLUMINANT` attribute.

  Examples

      >>> M_color_matrix_1 = np.array([
      ...     [0.5309, -0.0229, -0.0336],
      ...     [-0.6241, 1.3265, 0.3337],
      ...     [-0.0817, 0.1215, 0.6664]])
      >>> M_color_matrix_2 = np.array([
      ...     [0.4716, 0.0603, -0.0830],
      ...     [-0.7798, 1.5474, 0.2480],
      ...     [-0.1496, 0.1937, 0.6651]])
      >>> M_camera_calibration_1 = np.identity(3)
      >>> M_camera_calibration_2 = np.identity(3)
      >>> analog_balance = np.ones(3)
      >>> XYZ_to_camera_space_matrix(
      ...     np.array([0.34510414, 0.35162252]),
      ...     2850,
      ...     6500,
      ...     M_color_matrix_1,
      ...     M_color_matrix_2,
      ...     M_camera_calibration_1,
      ...     M_camera_calibration_2,
      ...     analog_balance)
      array([[ 0.4854908...,  0.0408106..., -0.0714282...],
             [-0.7433278...,  1.4956549...,  0.2680749...],
             [-0.1336946...,  0.1767874...,  0.6654045...]])

`colour_hdri.models.``camera_space_to_XYZ_matrix`(xy, CCT_calibration_illuminant_1, CCT_calibration_illuminant_2, M_color_matrix_1, M_color_matrix_2, M_camera_calibration_1, M_camera_calibration_2, analog_balance, M_forward_matrix_1, M_forward_matrix_2, chromatic_adaptation_transform=u'Bradford')

  Returns the Camera Space to CIE XYZ matrix for given xy white balance chromaticity coordinates.

  Parameters: | xy (array_like) – xy white balance chromaticity coordinates. CCT_calibration_illuminant_1 (numeric) – Correlated colour temperature of CalibrationIlluminant1. CCT_calibration_illuminant_2 (numeric) – Correlated colour temperature of CalibrationIlluminant2. M_color_matrix_1 (array_like) – ColorMatrix1 tag matrix. M_color_matrix_2 (array_like) – ColorMatrix2 tag matrix. M_camera_calibration_1 (array_like) – CameraCalibration1 tag matrix. M_camera_calibration_2 (array_like) – CameraCalibration2 tag matrix. analog_balance (array_like) – AnalogBalance tag vector. M_forward_matrix_1 (array_like) – ForwardMatrix1 tag matrix. M_forward_matrix_2 (array_like) – ForwardMatrix2 tag matrix. chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild’, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
  Returns: | Camera Space to CIE XYZ matrix.
  Return type: | ndarray

  Notes

  - The reference illuminant is D50 as defined per `ADOBE_DNG_XYZ_ILLUMINANT` attribute.

  References

  [6] | Adobe Systems. (2012). Camera to XYZ (D50) Transform. In Digital Negative (DNG) Specification (p. 81).

  Examples

      >>> M_color_matrix_1 = np.array([
      ...     [0.5309, -0.0229, -0.0336],
      ...     [-0.6241, 1.3265, 0.3337],
      ...     [-0.0817, 0.1215, 0.6664]])
      >>> M_color_matrix_2 = np.array([
      ...     [0.4716, 0.0603, -0.0830],
      ...     [-0.7798, 1.5474, 0.2480],
      ...     [-0.1496, 0.1937, 0.6651]])
      >>> M_camera_calibration_1 = np.identity(3)
      >>> M_camera_calibration_2 = np.identity(3)
      >>> analog_balance = np.ones(3)
      >>> M_forward_matrix_1 = np.array([
      ...     [0.8924, -0.1041, 0.1760],
      ...     [0.4351, 0.6621, -0.0972],
      ...     [0.0505, -0.1562, 0.9308]])
      >>> M_forward_matrix_2 = np.array([
      ...     [0.8924, -0.1041, 0.1760],
      ...     [0.4351, 0.6621, -0.0972],
      ...     [0.0505, -0.1562, 0.9308]])
      >>> camera_space_to_XYZ_matrix(
      ...     np.array([0.32816244, 0.34698169]),
      ...     2850,
      ...     6500,
      ...     M_color_matrix_1,
      ...     M_color_matrix_2,
      ...     M_camera_calibration_1,
      ...     M_camera_calibration_2,
      ...     analog_balance,
      ...     M_forward_matrix_1,
      ...     M_forward_matrix_2)
      array([[ 2.1604087..., -0.1041...    ,  0.2722498...],
             [ 1.0533324...,  0.6621...    , -0.1503561...],
             [ 0.1222553..., -0.1562...    ,  1.4398304...]])

`colour_hdri.models.``camera_space_to_RGB`(RGB, M_XYZ_to_camera_space, RGB_to_XYZ_matrix)

  Converts given RGB array from camera space to given RGB colourspace.

  Parameters: | RGB (array_like) – Camera space RGB colourspace array. XYZ_to_camera_matrix (array_like) – Matrix converting from CIE XYZ tristimulus values to camera space. RGB_to_XYZ_matrix (array_like) – Matrix converting from RGB colourspace to CIE XYZ tristimulus values.
  Returns: | RGB colourspace array.
  Return type: | ndarray

  Examples

      >>> RGB = np.array([0.80660, 0.81638, 0.65885])
      >>> M_XYZ_to_camera_space = np.array([
      ...     [0.47160000, 0.06030000, -0.08300000],
      ...     [-0.77980000, 1.54740000, 0.24800000],
      ...     [-0.14960000, 0.19370000, 0.66510000]])
      >>> RGB_to_XYZ_matrix = np.array([
      ...     [0.41238656, 0.35759149, 0.18045049],
      ...     [0.21263682, 0.71518298, 0.07218020],
      ...     [0.01933062, 0.11919716, 0.95037259]])
      >>> camera_space_to_RGB(
      ...     RGB,
      ...     M_XYZ_to_camera_space,
      ...     RGB_to_XYZ_matrix)
      array([ 0.7564180...,  0.8683192...,  0.6044589...])

`colour_hdri.models.``camera_space_to_sRGB`(RGB, M_XYZ_to_camera_space)

  Converts given RGB array from camera space to sRGB colourspace.

  Parameters: | RGB (array_like) – Camera space RGB colourspace array. M_XYZ_to_camera_space (array_like) – Matrix converting from CIE XYZ tristimulus values to camera space.
  Returns: | sRGB colourspace array.
  Return type: | ndarray

  Examples

      >>> RGB = np.array([0.80660, 0.81638, 0.65885])
      >>> M_XYZ_to_camera_space = np.array([
      ...     [0.47160000, 0.06030000, -0.08300000],
      ...     [-0.77980000, 1.54740000, 0.24800000],
      ...     [-0.14960000, 0.19370000, 0.66510000]])
      >>> camera_space_to_sRGB(RGB, M_XYZ_to_camera_space)
      array([ 0.7564350...,  0.8683155...,  0.6044706...])