2121from colour .algebra import LinearInterpolator , sdiv , sdiv_mode
2222from colour .colorimetry import SpectralDistribution , SpectralShape , reshape_sd
2323from colour .hints import NDArrayFloat
24- from colour .utilities import as_float_scalar , zeros
24+ from colour .utilities import zeros
2525
2626__author__ = "Colour Developers"
2727__copyright__ = "Copyright 2013 Colour Developers"
4444
4545
4646def 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 :
4951 """
5052 Return the *Academy Spectral Similarity Index* (SSI) of given test
5153 spectral distribution with given reference spectral distribution.
@@ -56,6 +58,9 @@ def spectral_similarity_index(
5658 Test spectral distribution.
5759 sd_reference
5860 Reference spectral distribution.
61+ round_results
62+ Controls rounding the results. Particularly useful when using SSI in an
63+ optimization routine. Default True.
5964
6065 Returns
6166 -------
@@ -143,6 +148,8 @@ def spectral_similarity_index(
143148 c_wdr_i = convolve1d (np .hstack ([0 , wdr_i , 0 ]), [0.22 , 0.56 , 0.22 ])
144149 m_v = np .sum (c_wdr_i ** 2 )
145150
146- SSI = np . around ( 100 - 32 * np .sqrt (m_v ) )
151+ SSI = 100 - 32 * np .sqrt (m_v )
147152
148- return as_float_scalar (SSI )
153+ if round_results :
154+ return np .around (SSI )
155+ return SSI
0 commit comments