Last active
April 22, 2020 11:37
-
-
Save bikz05/5a4bb314f18dad942b58 to your computer and use it in GitHub Desktop.
Color Difference using CIE DE2000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### colormath is needed to run the script | |
### Ubuntu users can get it by typing the 2 command below - | |
### `sudo apt-get install python-pip` | |
### `sudo pip install colormath` | |
from colormath.color_objects import sRGBColor, LabColor | |
from colormath.color_conversions import convert_color | |
from colormath.color_diff import delta_e_cie2000 | |
# Red Color | |
color1_rgb = sRGBColor(1.0, 0.0, 0.0); | |
# Blue Color | |
color2_rgb = sRGBColor(0.0, 0.0, 1.0); | |
# Convert from RGB to Lab Color Space | |
color1_lab = convert_color(color1_rgb, LabColor); | |
# Convert from RGB to Lab Color Space | |
color2_lab = convert_color(color2_rgb, LabColor); | |
# Find the color difference | |
delta_e = delta_e_cie2000(color1_lab, color2_lab); | |
print "The difference between the 2 color = ", delta_e | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
colormath is needed to run the script which has dependencies
numpy
python
2.7 and above.Ubuntu users can get it by typing the 2 command below -