Zephyr Scientific Library (zscilib)
Functions
Conversion Functions

Functions

int zsl_clr_conv_spd_xyz (const struct zsl_clr_spd *spd, enum zsl_clr_obs obs, struct zsl_clr_xyz *xyz)
 Converts the supplied spectral power distribution data into it's equivalent XYZ tristimulus using the specified standard observer model. More...
 
int zsl_clr_conv_xyy_xyz (struct zsl_clr_xyy *xyy, struct zsl_clr_xyz *xyz)
 Converts a CIE 1931 xyY chromaticity to its XYZ tristimulus equivalent. More...
 
int zsl_clr_conv_xyz_xyy (struct zsl_clr_xyz *xyz, struct zsl_clr_xyy *xyy)
 Converts CIE 1931 XYZ tristimulus values to the xyY chromaticity equivalent. More...
 
int zsl_clr_conv_xyy_uv60 (struct zsl_clr_xyy *xyy, struct zsl_clr_uv60 *uv)
 Converts a CIE 1931 xyY chromaticity to its CIE 1960 uv equivalent. More...
 
int zsl_clr_conv_xyz_uv60 (struct zsl_clr_xyz *xyz, struct zsl_clr_uv60 *uv)
 Converts CIE 1931 XYZ tristimulus values to its CIE 1960 uv equivalent. More...
 
int zsl_clr_conv_uv60_xyz (struct zsl_clr_uv60 *uv, struct zsl_clr_xyz *xyz)
 Converts a CIE 1960 uv value to its CIE 1931 XYZ tristimulus equivalent. More...
 
int zsl_clr_conv_uv60_xyy (struct zsl_clr_uv60 *uv, struct zsl_clr_xyy *xyy)
 Converts a CIE 1960 uv value to its CIE 1931 xyY chromaticity equivalent. More...
 
int zsl_clr_conv_uv60_uv76 (struct zsl_clr_uv60 *uv60, struct zsl_clr_uv76 *uv76)
 Converts a CIE 1960 uv value to its CIE 1976 u'v' equivalent. More...
 
int zsl_clr_conv_uv76_uv60 (struct zsl_clr_uv76 *uv76, struct zsl_clr_uv60 *uv60)
 Converts a CIE 1976 u'v' value to its CIE 1960 uv equivalent. More...
 
int zsl_clr_conv_ct_uv60 (zsl_real_t ct, enum zsl_clr_obs obs, struct zsl_clr_uv60 *uv)
 
int zsl_clr_conv_ct_xyz (zsl_real_t ct, enum zsl_clr_obs obs, struct zsl_clr_xyz *xyz)
 Converts an exact CIE 1960 CCT (Duv = 0.0) to a CIE 1931 XYZ tristimulus. More...
 
int zsl_clr_conv_ct_rgb8 (zsl_real_t ct, enum zsl_clr_obs obs, struct zsl_mtx *mtx, struct zsl_clr_rgb8 *rgb)
 Converts an exact CIE 1960 CCT (Duv = 0.0) to an 8-bit RGBA value using the supplied XYZ to RGB color space correlation matrix. More...
 
int zsl_clr_conv_ct_rgbf (zsl_real_t ct, enum zsl_clr_obs obs, struct zsl_mtx *mtx, struct zsl_clr_rgbf *rgb)
 Converts an exact CIE 1960 CCT (Duv = 0.0) to an floating point RGBA value using the supplied XYZ to RGB color space correlation matrix. More...
 
int zsl_clr_conv_cct_xyy (struct zsl_clr_cct *cct, enum zsl_clr_obs obs, struct zsl_clr_xyy *xyy)
 Converts a CIE 1960 CCT and Duv pair to a CIE 1931 xyY chromaticity. More...
 
int zsl_clr_conv_cct_xyz (struct zsl_clr_cct *cct, enum zsl_clr_obs obs, struct zsl_clr_xyz *xyz)
 Converts a CIE 1960 CCT and Duv pair to a CIE 1931 XYZ tristimulus. More...
 
int zsl_clr_conv_uv60_cct (enum zsl_clr_uv_cct_method method, struct zsl_clr_uv60 *uv, struct zsl_clr_cct *cct)
 Converts a CIE 1960 (u, v) pair to a CIE 1960 CCT and Duv pair using the specified conversion algorithm. More...
 
int zsl_clr_conv_xyz_rgb8 (struct zsl_clr_xyz *xyz, struct zsl_mtx *mtx, struct zsl_clr_rgb8 *rgb)
 Converts a CIE 1931 XYZ tristimulus to an 8-bit RGBA value using the supplied XYZ to RGB color space correlation matrix. More...
 
int zsl_clr_conv_xyz_rgbf (struct zsl_clr_xyz *xyz, struct zsl_mtx *mtx, struct zsl_clr_rgbf *rgb)
 Converts a CIE 1931 XYZ tristimulus to an floating point RGBA value using the supplied XYZ to RGB color space correlation matrix. More...
 

Detailed Description

Helper functions to convert between color systems and coordinates.

Function Documentation

◆ zsl_clr_conv_cct_xyy()

int zsl_clr_conv_cct_xyy ( struct zsl_clr_cct cct,
enum zsl_clr_obs  obs,
struct zsl_clr_xyy xyy 
)

Converts a CIE 1960 CCT and Duv pair to a CIE 1931 xyY chromaticity.

Parameters
cctPointer to CIE 1960 correlated color temperature and Duv.
obsThe CIE standard observer model to use for the conversion.
xyyPointer to the output CIE 1931 xyY chromaticity.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_cct_xyz()

int zsl_clr_conv_cct_xyz ( struct zsl_clr_cct cct,
enum zsl_clr_obs  obs,
struct zsl_clr_xyz xyz 
)

Converts a CIE 1960 CCT and Duv pair to a CIE 1931 XYZ tristimulus.

Parameters
cctPointer to CIE 1960 correlated color temperature and Duv.
obsThe CIE standard observer model to use for the conversion.
xyzPointer to the output CIE 1931 XYZ tristimulus.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_ct_rgb8()

int zsl_clr_conv_ct_rgb8 ( zsl_real_t  ct,
enum zsl_clr_obs  obs,
struct zsl_mtx mtx,
struct zsl_clr_rgb8 rgb 
)

Converts an exact CIE 1960 CCT (Duv = 0.0) to an 8-bit RGBA value using the supplied XYZ to RGB color space correlation matrix.

Parameters
ctThe color temperature to use.
obsThe CIE standard observer model to use for the conversion.
mtxPointer to the 3x3 XYZ to RGB color space correlation matrix.
rgbPointer to the output zsl_clr_rgb8 value.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_ct_rgbf()

int zsl_clr_conv_ct_rgbf ( zsl_real_t  ct,
enum zsl_clr_obs  obs,
struct zsl_mtx mtx,
struct zsl_clr_rgbf rgb 
)

Converts an exact CIE 1960 CCT (Duv = 0.0) to an floating point RGBA value using the supplied XYZ to RGB color space correlation matrix.

Parameters
ctThe color temperature to use.
obsThe CIE standard observer model to use for the conversion.
mtxPointer to the 3x3 XYZ to RGB color space correlation matrix.
rgbPointer to the output zsl_clr_rgbf value.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_ct_uv60()

int zsl_clr_conv_ct_uv60 ( zsl_real_t  ct,
enum zsl_clr_obs  obs,
struct zsl_clr_uv60 uv 
)

Convert the specified color temperature to a (u,v) chromaticity.

Parameters
ctThe color temperature to use.
obsThe CIE standard observer model to use for the conversion.
uvPointer to the output (u,v) chromaticity.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_ct_xyz()

int zsl_clr_conv_ct_xyz ( zsl_real_t  ct,
enum zsl_clr_obs  obs,
struct zsl_clr_xyz xyz 
)

Converts an exact CIE 1960 CCT (Duv = 0.0) to a CIE 1931 XYZ tristimulus.

Parameters
ctThe color temperature to use.
obsThe CIE standard observer model to use for the conversion.
xyzPointer to the output CIE 1931 XYZ tristimulus.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_spd_xyz()

int zsl_clr_conv_spd_xyz ( const struct zsl_clr_spd spd,
enum zsl_clr_obs  obs,
struct zsl_clr_xyz xyz 
)

Converts the supplied spectral power distribution data into it's equivalent XYZ tristimulus using the specified standard observer model.

Parameters
spdPointer to the spectral power distribution data to use.
obsThe CIE standard observer model to use for the conversion.
xyzPointer to the placeholder for the output XYZ tristimulus.
Returns
0 on normal execution, otherwise an appropriate error code.

◆ zsl_clr_conv_uv60_cct()

int zsl_clr_conv_uv60_cct ( enum zsl_clr_uv_cct_method  method,
struct zsl_clr_uv60 uv,
struct zsl_clr_cct cct 
)

Converts a CIE 1960 (u, v) pair to a CIE 1960 CCT and Duv pair using the specified conversion algorithm.

Parameters
methodThe algoorithm to use for the conversion.
uvPointer to input CIE 1960 (u, v) pair.
cctPointer to output zsl_clr_cct.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_uv60_uv76()

int zsl_clr_conv_uv60_uv76 ( struct zsl_clr_uv60 uv60,
struct zsl_clr_uv76 uv76 
)

Converts a CIE 1960 uv value to its CIE 1976 u'v' equivalent.

Parameters
uv60Pointer to the input CIE 1960 u,v pair.
uv76Pointer to the input CIE 1976 u',v' pair.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_uv60_xyy()

int zsl_clr_conv_uv60_xyy ( struct zsl_clr_uv60 uv,
struct zsl_clr_xyy xyy 
)

Converts a CIE 1960 uv value to its CIE 1931 xyY chromaticity equivalent.

Parameters
uvPointer to the input CIE 1960 u,v pair.
xyyPointer to the output xyY triplet.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_uv60_xyz()

int zsl_clr_conv_uv60_xyz ( struct zsl_clr_uv60 uv,
struct zsl_clr_xyz xyz 
)

Converts a CIE 1960 uv value to its CIE 1931 XYZ tristimulus equivalent.

Parameters
uvPointer to the input CIE 1960 u,v pair.
xyzPointer to the output XYZ tristimulus.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_uv76_uv60()

int zsl_clr_conv_uv76_uv60 ( struct zsl_clr_uv76 uv76,
struct zsl_clr_uv60 uv60 
)

Converts a CIE 1976 u'v' value to its CIE 1960 uv equivalent.

Parameters
uv76Pointer to the input CIE 1976 u',v' pair.
uv60Pointer to the input CIE 1960 u,v pair.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyy_uv60()

int zsl_clr_conv_xyy_uv60 ( struct zsl_clr_xyy xyy,
struct zsl_clr_uv60 uv 
)

Converts a CIE 1931 xyY chromaticity to its CIE 1960 uv equivalent.

Parameters
xyyPointer to the input xyY triplet.
uvPointer to the output CIE 1960 u,v pair.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyy_xyz()

int zsl_clr_conv_xyy_xyz ( struct zsl_clr_xyy xyy,
struct zsl_clr_xyz xyz 
)

Converts a CIE 1931 xyY chromaticity to its XYZ tristimulus equivalent.

Parameters
xyyPointer to the input xyY triplet.
xyzPointer to the output XYZ triplet.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyz_rgb8()

int zsl_clr_conv_xyz_rgb8 ( struct zsl_clr_xyz xyz,
struct zsl_mtx mtx,
struct zsl_clr_rgb8 rgb 
)

Converts a CIE 1931 XYZ tristimulus to an 8-bit RGBA value using the supplied XYZ to RGB color space correlation matrix.

Parameters
xyzThe input CIE 1931 XYZ tristimulus value to convert to RGB.
mtxPointer to the 3x3 XYZ to RGB color space correlation matrix.
rgbPointer to the output zsl_clr_rgb8 value.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyz_rgbf()

int zsl_clr_conv_xyz_rgbf ( struct zsl_clr_xyz xyz,
struct zsl_mtx mtx,
struct zsl_clr_rgbf rgb 
)

Converts a CIE 1931 XYZ tristimulus to an floating point RGBA value using the supplied XYZ to RGB color space correlation matrix.

Depending on the value of CONFIG_ZSL_CLR_RGBF_BOUND_CAP, the output values may be outside of the 0.0..1.0 range if the resulting value is out of gamut for the specified RGB color space.

Parameters
xyzThe input CIE 1931 XYZ tristimulus value to convert to RGB.
mtxPointer to the 3x3 XYZ to RGB color space correlation matrix.
rgbPointer to the output zsl_clr_rgbf value.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyz_uv60()

int zsl_clr_conv_xyz_uv60 ( struct zsl_clr_xyz xyz,
struct zsl_clr_uv60 uv 
)

Converts CIE 1931 XYZ tristimulus values to its CIE 1960 uv equivalent.

Parameters
xyzPointer to the input zsl_clr_xyz triplet.
uvPointer to the output CIE 1960 u,v pair.
Returns
0 on success, error code on failure.

◆ zsl_clr_conv_xyz_xyy()

int zsl_clr_conv_xyz_xyy ( struct zsl_clr_xyz xyz,
struct zsl_clr_xyy xyy 
)

Converts CIE 1931 XYZ tristimulus values to the xyY chromaticity equivalent.

Parameters
xyzPointer to the input XYZ triplet.
xyyPointer to the output xyY triplet.
Returns
0 on success, error code on failure.