# ZtoRGBpy

Version 1.0.1 Documentation

# ZtoRGBpy.RGBColorProfile¶

class RGBColorProfile(weights=(2126.0, 7152.0, 722.0), gamma=0.5)[source]

Defines a color profile in a given RGB color space by conversion factors for red, green and blue to the Y component of the XYZ color space, i.e. the white point.

Parameters: weights (tuple [ float, float, float ], optional, default: (2126.0, 7152.0, 772.0)) – Color component weight triple ($$W_R, W_G, W_B$$) for conversion to the XYZ color space Defaults to the sRGB color space defined by IEC. gamma (float, optional, defaults: 0.5) – Gamma ($$\gamma$$) correction.
apply_gamma(rgb)[source]

Applies gamma correction to color

Parameters: rgb (array_like […]) – non-gamma corrected RGB color values RGB (array [ rgb.shape ]) – gamma corrected RGB color values

Notes

Equivalent to $${RGB} = {rgb}^{\gamma}$$

get_chroma_limit()[source]

Return the limiting chroma

Returns: chroma_limit (float) – Limiting Chroma for the colorspace

Notes

The limiting chroma is computed from the transformation matrix as described in Fletcher 2019.

get_limits()[source]

Returns $$U_{max}$$ and $$V_{max}$$

Returns: Vmax (float) – V channel magnitude limit ($$V_{max}$$) Umax (float) – U channel magnitude limit ($$U_{max}$$)

Notes

$$U_{max}$$ and $$V_{max}$$ represent the limits of the UV color space, as defined by:

$\begin{split}V_{max} =& \frac{\sqrt{K_R}}{\sqrt{K_R} + \sqrt{K_B}}\\ U_{max} =& \frac{\sqrt{K_B}}{\sqrt{K_R} + \sqrt{K_B}}\end{split}$
get_ratios()[source]

Returns the relative ratios for red and blue

Returns: red_ratio (float) – Relative ratio of red ($$K_R$$) blue_ratio (float) – Relative ratio of blue ($$K_B$$)

Notes

Ratios for red ($$K_R$$) and blue ($$K_B$$) are defined by:

$\begin{split}K_R =& \frac{W_R}{W_R + W_G + W_B}\\ K_B =& \frac{W_B}{W_R + W_G + W_B}\end{split}$
get_transform()[source]

Returns the UV to RGB transformation matrix $$\mathbf{K_Q}$$.

Returns: transformation (array [3, 2, dtype = float]) – transformation matrix $$\mathbf{K_Q}$$

Notes

The transformation matrix $$\mathbf{K_Q}$$ is defined by:

$\begin{split}\mathbf{K_Q} &= \left[\begin{matrix} 0 & \frac{1-K_R}{V_{max}} \\ \frac{K_B\left( 1-K_B \right)}{U_{max}\left( K_B+K_R-1 \right)} & \frac{K_R\left( 1-K_R \right)}{V_{max}\left( K_B+K_R-1 \right)}\\ \frac{1-K_B}{U_{max}} & 0 \\ \end{matrix}\right]\end{split}$
remove_gamma(RGB)[source]

Removes gamma correction from color

Parameters: RGB (array_like […]) – gamma corrected RGB color values rgb (array [ RGB.shape ]) – non-gamma corrected RGB color values

Notes

Equivalent to $${rgb} = {RGB}^{\frac{1}{\gamma}}$$

## Predefined Color Profiles¶

 sRGB_LOW Defines a color profile in a given RGB color space by conversion factors for red, green and blue to the Y component of the XYZ color space, i.e. sRGB_HIGH Defines a color profile in a given RGB color space by conversion factors for red, green and blue to the Y component of the XYZ color space, i.e. sRGB Defines a color profile in a given RGB color space by conversion factors for red, green and blue to the Y component of the XYZ color space, i.e.

  (1, 2, 3) Glen Fletcher. A Perceptually Uniform RGB Subset for Representing Complex-valued Data. Technical Report, University of Technology Sydney, 2019. URL: https://glenfletcher.com/research/a-perceptually-uniform-rgb-subset-for-representing-complex-valued-data/.
  International Electrotechnical Commission. Colour Measurement and Management in Multimedia Systems and Equipment. 1998. URL: http://www2.units.it/ipl/students_area/imm2/files/Colore1/sRGB.pdf.