Generating Reflectance Curves from sRGB Triplets (Page 4)

Least Slope Squared (LSS) Method

Note that the standard LLS method minimizes \rho^\mathsf{T}\rho, that is, it finds the solution that is nearest to the origin, or the reflectance curve that oscillates most tightly about the wavelength axis. For purposes of computing reflectance curves, I can’t think of a compelling reason why this should be a useful objective.

It dawned on me that it might be better to try a different objective function. The reflectance curves of most natural colored objects don’t tend to oscillate up and down very much. I came up with the idea to minimize the square of the slope of the reflectance curve, summed over the entire curve. In the continuous case, this would be equivalent to

    \[\mathsf{min} \int_{visible\;\lambda} (d\rho / d\lambda)^2\;d\lambda.\]

The square is used because it equally penalizes upward and downward movement of \rho. This objective will favor flatter reflectance curves and avoid curves that have a lot of up and down movement. (Edit: I later learned that this objective function has been previously investigated by C van Trigt in 1990 in a series of papers called “Smoothest Reflectance Functions.”)

Other researchers have developed methods for reconstructing reflectance curves from tristimulus values. In order to reduce the oscillations, they typically introduce basis functions that oscillate very little, such as segments of low-frequency sinusoids, or they “frequency limit” or “band limit” the solution by constraining portions of the Fourier transform of the reflectance curve. To my mind, these approaches seem to ignore that fact that realistic reflectance curves can sometimes exhibit sudden steep changes in reflectance at certain frequencies, which would have relatively large high-frequency Fourier components. These methods would not be able to create such reflectance curves.

My proposed method would be able to create steep changes in reflectance, but only as a last resort when flatter-sloped curves are not able to match the target tristimulus values. The other advantage of the minimum slope squared approach is that it can be expressed as a quadratic objective function subject to linear constraints, which is solvable by standard least-square strategies.

Consider this optimization formulation:

    \[\begin{split}\mathsf{minimize}\;\;&\sum_{i=1}^{n-1} (\rho_{i+1} - \rho_i)^2 \\ \mathsf{s.t.}\;\;&T \rho = rgb,\end{split}\]

where n is the number of discrete wavelength bands (36 in this study). This optimization can be solved by solving the system of linear equations arising from the Lagrangian stationary conditions

    \[\left[\begin{array}{cc} D & T^\mathsf{T} \\ T & 0 \end{array}\right] \begin{Bmatrix}\rho\\\lambda\end{Bmatrix} = \begin{Bmatrix}0\\rgb\end{Bmatrix},\]

where D is a 36\mathsf{x}36 tridiagonal matrix

    \[D=\begin{bmatrix}2 & -2\\-2 & 4 & -2\\ & -2 & 4 & -2 \\ & & \ddots & \ddots & \ddots \\ & & & -2 & 4 & -2 \\ & & & & -2 & 2 \end{bmatrix}.\]

Since D and T do not depend on rgb, the matrix can be inverted ahead of time, instead of each time an sRGB value is processed. Defining

    \[ B = \left[ \begin{array}{cc} D & T^\mathsf{T} \\ T & 0 \end{array} \right]^{-1} = \left[ \begin{array}{cc} B_{11} & B_{12} \\ B_{21} & B_{22} \end{array} \right], \]

we have

    \[ \begin{Bmatrix}\rho\\\lambda\end{Bmatrix}= \left[ \begin{array}{cc} B_{11} & B_{12} \\ B_{21} & B_{22} \end{array} \right] \begin{Bmatrix}0\\rgb\end{Bmatrix} \]


    \[\rho = B_{12}\;rgb,\]

where B_{12} is the upper-right 36\mathsf{x}3 portion of the B matrix. Alternatively, the matrix inversion leading to B_{12} can be done explicitly through the formula:

    \[ B_{12}=(D^\mathsf{T}D+T^\mathsf{T}T-D^\mathsf{T}T^\mathsf{T}(T T^\mathsf{T})^{-1}T D)^{-1}T^\mathsf{T} \]

Note that this long formula is much less efficient than simply extracting the upper-right 36\mathsf{x}3 portion of the B matrix. The 36×3 B_{12} matrix is shown here.

Since computing \rho is a simple matter of matrix multiplication, the LSS method is just as computationally efficient as the LLS method, and tends to give much better reflectance curves, as I’ll demonstrate later.

Here is a Matlab program for the LSS (Least Slope Squared) method. It also works in the open source free alternative to Matlab, called Octave.


The presentation is spread over several web pages. Click the Next Page or Previous Page links to move sequentially. To access a page directly, use these links:

1. Introduction
2. Computing an sRGB triplet from a Reflectance Curve
3. Linear Least Squares (LLS) Method
4. Least Slope Squared (LSS) Method (this page)
5. Least Log Slope Squared (LLSS) Method
6. Iterative Least Log Slope Squared (ILLSS) Method
7. Iterative Least Slope Squared (ILSS) Method
8. Comparison of Methods
9. Conclusions (pre-6/4/19)
10. Update 6/4/19: Least Hyperbolic Tangent Slope Squared (LHTSS) Method

← Previous Page Next Page →