Xrite Color Profiles ?

Started 10 months ago | Discussions thread
Jack Hogan Veteran Member • Posts: 8,008
Re: Pinv and the Normal Equation

Xasan wrote:

Jack Hogan wrote:

Xasan wrote:

Calculating M0 as pinv(raw' * raw) * raw' * xyzRef;

7.3014e-01 2.8669e-01 7.4507e-02
2.2482e-01 9.5975e-01 -3.1573e-01
7.3872e-03 -2.3704e-01 1.1420e+00

avg. dE00 = 16.873

Calculating M0 as xyzRef' * pinv(raw'):

7.3014e-01 2.2482e-01 7.3872e-03
2.8669e-01 9.5975e-01 -2.3704e-01
7.4507e-02 -3.1573e-01 1.1420e+00

avg. dE00 = 1.4427

The difference between M0 matrices is - transpose.

In any case for reference in Matlab the fastest solution of those above seems to be provided by

inv(raw' * raw) * raw' * xyzRef

That would result in the same relatively large dE. A typo or I'm missing something here?

The difference is due to where the matrix is coming from and where it is going.

It comes by solving Ax = b for x, with variables columnwise (Nx3).  So in our notation:

raw * M0 = xyzRef, or

M0 = pinv(raw) * xyzRef.

Alternatively, thanks to the Normal Equation:

M0 = inv(raw'*raw) * raw' * xyzRef

Figure 1

which match as expected. However the resulting matrix is going to be deployed as a Forward Matrix (per DNG specs and the article ), where it is used as shown below with variables rowwise (3xN) so that xyz = M * rgb

Equation (1)

To achieve Equation (1) with the variables as we have them we write

b'= (Ax)' = (raw * M0)' or equivalently M0' * raw'

Therefore the Forward Matrix as defined in Equation (1) is the transpose of what is calculated in Figure 1.

We could also solve Equation (1) directly for M = xyzRef' * pinv(raw') to prove that M is M0', as you did in yellow above.

I handle this slightly differently in the code attached to the article but perhaps I will change it back to make it easier to follow. I will also update it based on the discussion in this thread:

  1. inv instead of pinv; and
  2. I will no longer white balance the raw data in the function, just compensate exposure so that L*50 neutral patch 22 matches the relative Y reference.

Having accurate white balance multipliers, independently of profiling workflow, is a pre-requisite for good color. However white balancing the raw data to start with is not strictly necessary: the routine will happily find a CCM with white balance baked in for the given setup, though clearly losing flexibility and compatibility with the DNG workflow.


Post (hide subjects) Posted by
Keyboard shortcuts:
FForum PPrevious NNext WNext unread UUpvote SSubscribe RReply QQuote BBookmark MMy threads
Color scheme? Blue / Yellow