From 8d55aca6eae02415e3ef2f7841dc96b117d56324 Mon Sep 17 00:00:00 2001 From: markwbrown Date: Mon, 21 Mar 2016 20:42:58 -0700 Subject: [PATCH 1/2] Update color_diff.py Default CIEDE200 changed to use unity 1 in Kl, Kc, Kh without passing as args. delta_e_cie2000_nonunity(color1, color2, Kl, Kc, Kh) proposed as new function to allow for passing in Kl, Kc, Kh in instances which a different weighting factor, or nonunity weighting factors are desired. --- colormath/color_diff.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/colormath/color_diff.py b/colormath/color_diff.py index 891acae..42bda01 100644 --- a/colormath/color_diff.py +++ b/colormath/color_diff.py @@ -69,9 +69,20 @@ def delta_e_cie1994(color1, color2, K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015): color1_vector, color2_matrix, K_L=K_L, K_C=K_C, K_H=K_H, K_1=K_1, K_2=K_2)[0] return numpy.asscalar(delta_e) +# noinspection PyPep8Naming +def delta_e_cie2000(color1, color2): + """ + Calculates the Delta E (CIE2000) of two colors. + """ + color1_vector = _get_lab_color1_vector(color1) + color2_matrix = _get_lab_color2_matrix(color2) + delta_e = color_diff_matrix.delta_e_cie2000( + color1_vector, color2_matrix, Kl=1, Kc=1, Kh=1)[0] + return numpy.asscalar(delta_e) + # noinspection PyPep8Naming -def delta_e_cie2000(color1, color2, Kl=1, Kc=1, Kh=1): +def delta_e_cie2000_nonunity(color1, color2, Kl, Kc, Kh): """ Calculates the Delta E (CIE2000) of two colors. """ From 149e69ab4f29c5bd7a20180bfa53809103df81db Mon Sep 17 00:00:00 2001 From: markwbrown Date: Mon, 21 Mar 2016 22:02:03 -0700 Subject: [PATCH 2/2] DECIE2000 depreciation warning Rolled back delta_e_cie2000 to original with depreciation warning. delta_e_cie2000_update added as reference to know what to expect in a future release. --- colormath/color_diff.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/colormath/color_diff.py b/colormath/color_diff.py index 42bda01..022229c 100644 --- a/colormath/color_diff.py +++ b/colormath/color_diff.py @@ -70,17 +70,27 @@ def delta_e_cie1994(color1, color2, K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015): return numpy.asscalar(delta_e) # noinspection PyPep8Naming -def delta_e_cie2000(color1, color2): +def delta_e_cie2000(color1, color2, Kl=1, Kc=1, Kh=1): """ Calculates the Delta E (CIE2000) of two colors. """ - + from warnings import warn + warn("The current form of this class being depreciated in favor of not passing in arguments for Kl, Kc, and Kh when unity 1 is used. For applications wishing to retain the ability to change Kl, Kc, and/or Kh from default value of 1 see delta_e_cie_2000_nonunity. In a future release, the updated format as seen in delta_e_cie2000_update will be used") color1_vector = _get_lab_color1_vector(color1) color2_matrix = _get_lab_color2_matrix(color2) delta_e = color_diff_matrix.delta_e_cie2000( - color1_vector, color2_matrix, Kl=1, Kc=1, Kh=1)[0] + color1_vector, color2_matrix, Kl=Kl, Kc=Kc, Kh=Kh)[0] return numpy.asscalar(delta_e) +def delta_e_cie2000_update (color1, color2): + """ + Calculates the Delta E (CIE2000) of two colors. + """ + color1_vector = _get_lab_color1_vector(color1) + color2_matrix = _get_lab_color2_matrix(color2) + delta_e = color_diff_matrix.delta_e_cie2000( + color1_vector, color2_matrix, Kl=1, Kc=1, Kh=1)[0] + return numpy.asscalar(delta_e) # noinspection PyPep8Naming def delta_e_cie2000_nonunity(color1, color2, Kl, Kc, Kh): """