21
21
from colour .algebra import LinearInterpolator , sdiv , sdiv_mode
22
22
from colour .colorimetry import SpectralDistribution , SpectralShape , reshape_sd
23
23
from colour .hints import NDArrayFloat
24
- from colour .utilities import as_float_scalar , zeros
24
+ from colour .utilities import zeros
25
25
26
26
__author__ = "Colour Developers"
27
27
__copyright__ = "Copyright 2013 Colour Developers"
44
44
45
45
46
46
def spectral_similarity_index (
47
- sd_test : SpectralDistribution , sd_reference : SpectralDistribution
48
- ) -> float :
47
+ sd_test : SpectralDistribution ,
48
+ sd_reference : SpectralDistribution ,
49
+ round_results : bool = True ,
50
+ ) -> NDArrayFloat :
49
51
"""
50
52
Return the *Academy Spectral Similarity Index* (SSI) of given test
51
53
spectral distribution with given reference spectral distribution.
@@ -56,6 +58,9 @@ def spectral_similarity_index(
56
58
Test spectral distribution.
57
59
sd_reference
58
60
Reference spectral distribution.
61
+ round_results
62
+ Controls rounding the results. Particularly useful when using SSI in an
63
+ optimization routine. Default True.
59
64
60
65
Returns
61
66
-------
@@ -143,6 +148,8 @@ def spectral_similarity_index(
143
148
c_wdr_i = convolve1d (np .hstack ([0 , wdr_i , 0 ]), [0.22 , 0.56 , 0.22 ])
144
149
m_v = np .sum (c_wdr_i ** 2 )
145
150
146
- SSI = np . around ( 100 - 32 * np .sqrt (m_v ) )
151
+ SSI = 100 - 32 * np .sqrt (m_v )
147
152
148
- return as_float_scalar (SSI )
153
+ if round_results :
154
+ return np .around (SSI )
155
+ return SSI
0 commit comments