Generating Reflectance Curves from sRGB Triplets (Page 7)

Iterative Least Slope Squared (ILSS) Method

For completeness, I thought it would be a good idea to add one more algorithm. Recall the ILLSS method modifies the LLSS method to cap reflectances >1. Similarly, the ILSS method will modify the LSS method to cap values both >1 and <0. The ILSS may reduce computational effort in comparison to the ILLSS method since the inner loop of the ILLSS method requires an iterative Newton’s method solution, whereas there would be no inner loop needed with the ILSS method; it is simply the solution of a linear system of equations. Here is the ILSS formulation:

    \[\begin{split}\mathsf{minimize}\;\;&\sum_{i=1}^{35} (\rho_{i+1} - \rho_i)^2 \\ \mathsf{s.t.}\;\;&T \rho = rgb \\ &\rho_{k_1} = 1,\;\;k_1\in \mathsf{FixedSet_1}\\ &\rho_{k_0} = \rho_{min},\;\;k_0\in \mathsf{FixedSet_0}.\end{split}\]

\mathsf{FixedSet_1} is the set of reflectance indices that are constrained to equal 1, and \mathsf{FixedSet_0} is the set of indices that are constrained to equal \rho_{min} (the smallest allowable reflectance, typically 0.00001). Initially, both fixed sets are the empty set. Each time the optimization is repeated, the \rho values \ge 1 have their indices added to \mathsf{FixedSet_1} and those \le \rho_{min} have their indices added to \mathsf{FixedSet_0}.

We define two matrices that summarize the fixed sets, for example:

    \[K_1=\left [ \begin{array}{cccccccc} 0&0&1&0&0&0&\hdots&0\\ 0&0&0&0&1&0&\hdots&0\end{array} \right ]_{2\mathsf{x}36}\]

    \[K_0=\left [ \begin{array}{cccccccc} 1&0&0&0&0&0&\hdots&0\\ 0&0&0&0&0&1&\hdots&0\\ 0&0&0&1&0&0&\hdots&0\end{array} \right ]_{3\mathsf{x}36}.\]

This example indicates that there are two reflectance values being constrained to equal 1 (because K_1 has two rows), and the third and fifth reflectance values are the particular ones being constrained. There are three reflectance values being constrained to \rho_{min} (because K_0 has three rows), and the first, sixth, and fourth are the particular ones being constrained. The order in which the rows appear in these matrices is not important.

At each iteration of the ILSS method, this linear system is solved:

    \[\left[\begin{array}{cccc} D & T^\mathsf{T} & K_1^\mathsf{T} & K_0^\mathsf{T}\\ T & 0 & 0 & 0\\ K_1 & 0 & 0 & 0\\ K_0 & 0 & 0 & 0\end{array}\right] \begin{Bmatrix}\rho\\\lambda\\\mu\\\nu\end{Bmatrix} = \begin{Bmatrix}0\\rgb\\1\\\rho_{min}\end{Bmatrix},\]

where \mu and \nu are Lagrange multipliers associated with the K_1 and K_0 sets, respectively.

This system can be solved for \rho, yielding the expression

    \[\rho = R - B_{11} K^\mathsf{T} \left [K B_{11} K^\mathsf{T}\right ]^{-1} \left (K R - \begin{Bmatrix}1\\\rho_{min}\end{Bmatrix}\right ),\]


    \[ B = \left[\begin{array}{cc} D & T^\mathsf{T} \\ T & 0 \end{array}\right]^{-1},\;\;\;\; R=B_{12}\;rgb, \;\;\;\; \mathrm{and}\;\;\;K=\begin{bmatrix}K_1\\K_0\end{bmatrix}.\]

B_{11} and B_{12} are the upper-left 36\mathsf{x}36 and upper-right 36\mathsf{x}3 parts of B, respectively. They can be computed ahead of time. Note that only an m\mathsf{x}m matrix needs to be inverted at each iteration, where m is the number of \rho values being held fixed, typically zero or a small number. When m is zero, the ILSS method simplifies to the LSS method. Here is a Matlab program that performs the ILSS (Iterative Least Slope Squared) method. It also works in Octave. Matlab code can be dense and difficult to read, so I’ve prepared a line-by-line commentary for understanding the code.

Here are my notes on deriving the expression for \rho:
ILSS rho derivation


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
5. Least Log Slope Squared (LLSS) Method
6. Iterative Least Log Slope Squared (ILLSS) Method
7. Iterative Least Slope Squared (ILSS) Method (this page)
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 →