color.py¶
Sub-module providing color functions.
References,
Measuring Colour by R.W.G. Hunt and M.R. Pointer
- rgb_to_xyz(red, green, blue)[source]¶
Convert standard RGB color to XYZ color.
D65/2° standard illuminant.
- dist_rgb(rgb1, rgb2)[source]¶
Determine distance between two rgb colors.
- Parameters:
- Returns:
Square of the distance between provided colors
- Return type:
This works by treating RGB colors as coordinates in three dimensional space and finding the closest point within the configured color range using the formula:
d^2 = (r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2
For efficiency, the square of the distance is returned which is sufficient for comparisons
- dist_rgb_weighted(rgb1, rgb2)[source]¶
Determine the weighted distance between two rgb colors.
- Parameters:
- Returns:
Square of the distance between provided colors
- Return type:
float Similar to a standard distance formula, the values are weighted to approximate human perception of color differences For efficiency, the square of the distance is returned which is sufficient for comparisons
- dist_cie76(rgb1, rgb2)[source]¶
Determine distance between two rgb colors using the CIE94 algorithm.
- dist_cie94(rgb1, rgb2)[source]¶
Determine distance between two rgb colors using the CIE94 algorithm.