Skip to content

Commit

Permalink
Fix numerical precision issue in colour.difference.delta_E_CIE1994
Browse files Browse the repository at this point in the history
…definition.

Closes #1206.
  • Loading branch information
KelSolaar committed Oct 13, 2023
1 parent bf10e38 commit 0717251
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions colour/difference/delta_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from colour.algebra import euclidean_distance
from colour.hints import ArrayLike, NDArrayFloat
from colour.utilities import as_float, to_domain_100, tsplit
from colour.utilities import as_float, to_domain_100, tsplit, zeros
from colour.utilities.documentation import (
DocstringFloat,
is_documentation_building,
Expand Down Expand Up @@ -225,7 +225,9 @@ def delta_E_CIE1994(
delta_A = a_1 - a_2
delta_B = b_1 - b_2

delta_H = np.sqrt(delta_A**2 + delta_B**2 - delta_C**2)
radical = delta_A**2 + delta_B**2 - delta_C**2
delta_H = zeros(radical.shape)
delta_H[radical > 0] = np.sqrt(radical[radical > 0])

L = (delta_L / (k_L * s_L)) ** 2
C = (delta_C / (k_C * s_C)) ** 2
Expand Down

0 comments on commit 0717251

Please sign in to comment.