Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.7k stars 308 forks source link

A fine way of spending a Monday night - DCP profile, color matrix, illuminant #4150

Open Beep6581 opened 6 years ago

Beep6581 commented 6 years ago

As a result of an IRC chat with @agriggio , here is a comparison of dual-illuminant DCPs made in four ways using dcamprof:

http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20daylight%20summer.arw http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20daylight%20summer.arw.pp3 http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20daylight%20winter.arw http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20daylight%20winter.arw.pp3

http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20tungsten.arw http://rawtherapee.com/shared/test_images/colortarget/SONY%20ILCE-7M2%20tungsten.arw.pp3

In all cases it used: dcamprof make-profile -i as_above -C daylight.ti3 daylight.json and dcamprof make-profile -i StdA tungsten.ti3 tungsten.json for the StdA shot.

Beep6581 commented 6 years ago

I'm surprised to find no differences...

@atorger should we use -i D50 or -i D65 when the other parameters are as in https://github.com/pixlsus/Scripts/blob/master/generateDCP and should we update the matrices in camconst.json and if so, with what?

agriggio commented 6 years ago

necessary premise: consider that my knowledge about colour is pretty basic, so forgive me in advance and take what I write with a couple of grains of salt :-)

But, my understanding (from reading the RT code and the excellent docs of dcamprof at https://www.ludd.ltu.se/~torger/dcamprof.html#white_balance) is that it would be desirable to make sure that the DCP profiles shipped by RT use the same (D65) colour matrix as camconst.json, to have more "meaningful" temp/tint wb values computed. The hypothesis here is that the matrices in the DCP files are more accurate than what is currently in camconst.json, and so they should be preferred.

If my understanding is correct, this would have no impact on single illuminant files, but it might be visible for dual illuminant (because the mixing of the two matrices depends on the computed temperature), and it will also affect the usability of the standard wb settings. For example, with the current matrix in camconst.json for my Sony a6000, the standard wb settings result in very visible colour casts (typically too green).

What do you think? Does the above make any sense? (ping @iliasg and @atorger...)

atorger commented 6 years ago

I'm a bit rusty on all this. Camconst.json contains D65 dcraw matrices right? So if you want to replace there it should be with a D65 matrix.

If you render a single illuminant DCP my opinion is that D50 is the most all-around, partly as that is the reference illuminant in the color pipeline, but the difference to D65 is quite small.

For dual illuminant StdA + D65 is a good pair, Adobe (almost) always uses that and it provides a wide range of white balance.

RT has its own WB model and the DCP pipeline its own, the DCP wb is not shown in the GUI. The DCP matrices won't affect RT's model, which uses the camconst matrix.

agriggio commented 6 years ago

@atorger so if I understand correctly what you are saying, there's no hurry to change our matrices in camconst to match those in the DCP, right? In that case, I think we can close this for now...

agriggio commented 6 years ago

So, I finally found some time to dig a bit deeper and provide some evidence for what I have been seeing for a while (and failed to communicate up to now). Here's a link with the material: https://filebin.net/puciqmssrbqnnz5w

The two matrix-only dcp profiles AlbertoMatrix.json and DcamprofMatrix.json have the same forward matrices, but different colour matrices. In particular, AlbertoMatrix.json uses the matrix found in dcamprof.json (for the Sony a6000, the camera used here), adapted to StdA and D50 illuminants.

My understanding of the dcamprof docs was that the colour matrices were only used for WB and for "mixing" the two illuminants, but the actual colour corrections are done by the forward matrices. And yet, the two profiles produce different outputs, as shown by the attached ARW file. To reproduce, you first have to actually convert the json files into dcp, using dcamprof's json2dcp command. Then, apply the provided pp3, and export two copies of the image by simply changing the input profile. You will see some differences both in the red shirt and in the orange hair of Pippi (my daughter's favourite doll :-).

If you think this is hardly visible, I have pictures with people where the difference is much more noticeable. This has driven me crazy for a long time, because there were some pictures (typically under "weird" illuminants) for which I wasn't able to get a decent skin tone... with the AlbertoMatrix profile, I'm much happier now.

Commments?

Beep6581 commented 6 years ago

My understanding of the dcamprof docs was that the colour matrices were only used for WB and for "mixing" the two illuminants, but the actual colour corrections are done by the forward matrices. And yet, the two profiles produce different outputs

The docs say:

Dual-illuminant profiles is an exception. In that case you have two matrices, usually one for StdA and one for D65. Both these are then used to calculate the temperature and tint, and the derived temperature is then used to mix the two ForwardMatrices, that is if it’s exactly between the 6500K of D65 and 2850K of StdA then 50% of each is used. This means that the temperature derivation has some effect on the forward matrix and thus some effect on the color correction. So if you intend to make a dual-illuminant profile it’s required to provide a proper EXIF lightsource for each, and for the profile to make accurate temperature estimations the actual lights used during profiling should match the EXIF lightsource temperatures as well as possible.

The filebin is expired; I assume those were dual-illuminant jsons. Maybe it's the case that the difference in color matrices produces different temperature values which results in the StdA-D?? forward matrices being mixed differently.

Beep6581 commented 6 years ago

I still have questions, some of which I think I know the answers to, but I will ask anyway. These all assume we're talking about a dual-illuminant profile:

  1. If there is no color matrix for a given model in camconst.json, is one taken from dcraw.cc?
  2. If the matrix in dcraw.cc matches the one obtained by converting a raw file to DNG using Adobe DNG Converter and checking its metadata, does that mean that there is no point specifying it in camconst.json?
  3. What is the color matrix from dcraw/camconst used for in RT?
  4. What is the color matrix from the DCP profile used for and how does it coexist with the dcraw/camconst one?
  5. When generating a DCP using dcamprof one sees this in the output:
    Finding a camera raw RGB to CIE XYZ matrix for calibration illuminant D50...
    Whitest patch in target (D02) differs DE 1.22 from calibration illuminant,
      close enough to calculate whitepoint preservation.
    Inverting to get ColorMatrix:
      {
        "ColorMatrix1": [
          [  0.601970, -0.144775, -0.030959 ],
          [ -0.499462,  1.217856,  0.318550 ],
          [ -0.103870,  0.176350,  0.713730 ]
        ]
      }
    Matrix patch match average DE 1.50, DE LCh 0.82 0.60 0.88
                        median DE 1.45, DE LCh 0.78 0.49 0.77
                           p90 DE 2.56, DE LCh 1.53 1.44 1.46
                           max DE 3.76, DE LCh 2.65 1.80 3.69
    ColorMatrix optimal white balance for target: 0.410464,1,0.665744 (m2.43627,1,1.50208)

    What should I do with that information? Would it be beneficial to use it in camconst.json?

  6. What if the color matrix from dcraw/camconst is for D65 while I shot the target under clear daylight (D50) and while generating the DCP set the illuminant (correctly) to D50?
agriggio commented 6 years ago

@Beep6581 here are the answers to the best of my understanding (no warranty of correctness/exhaustiveness :-)

  1. yes

  2. yes

  3. for white balance

  4. for computing the illuminant temperature that is the used to combine/mix the two DCP profiles. It coexists with the dcraw/camconst one in the sense that they are used for different purposes, but if they are significantly off the temperature used for mixing the DCPs might be quite different from the temp computed by the WB module

  5. I think you could use it in camconst to solve the problem above, but you will probably have to adapt to D65 if it was computed using a different illuminant

  6. see point 4, the matrices are used for different purposes. But I think internally RT always uses D65

Now, FWIW I have moved away from DCP profiles in my normal use of RT, and I am now using a very simple "well behaved" matrix profile built by following Elle's instructions (https://ninedegreesbelow.com/photography/well-behaved-camera-profile.html). I find its behaviour more predictable under various lighting sources. No matter how hard I tried, with dual-illuminant DCPs I was always fighting against some unpleasant colour shifts under some circumstances... clearly YMMV.

Beep6581 commented 5 years ago

Removing milestone, but leaving issue open for further experimentation.