Question: Colour Science, LUTs, and AgX in Darktable

First, I know just enough at this point to be dangerous, so please forgive any gross errors! Also, this is a question about whether an idea I just had is feasible, not a proposal!

I use Fuji X series cameras, and rather enjoy the idea of film simulations. There are lots of discussions out there on film simulations, and some interesting software about generating 3D-LUTs from RAW and in-camera processed images. These appear to work well, but come with some limitations, especially that they replace the tone mapper, such as AgX.

In other words, the image processing looks like Y=(f°g)(X), where X is the raw image, Y is the processed image, f represents all of the processing up to the LUT (or scene mapper), and g represents either the LUT or the scene mapper.

It seems to me that if the scene mapper at its default settings could be modelled as an invertable function, such as another LUT, then one could look at image processing as (f°s°g)(x) where f is as before, s is a LUT designed to be applied before scene mapping, and g is the scene mapper, such as AgX.

If that was the case, then one ought to be able to generate the lut s using g⁻Âč(Y) as the target processed image.

Such a LUT would be applied before scene mapping, and would be defined on darktable’s usual colour space and bit depth. That would make it a lot more like any other module.

So, is that idea crazy, or is the behaviour of scene mapping modules like AgX (at some fixed setting) too input dependent for an inverse function to be easily approximated?

Fuji’s film simulation is just another picture formation (which takes camera exposure data that you cannot directly see, and turn it into a picture that you can actually see), using it replaces AgX in your workflow, it is just like using AgX replaces Filmic RGB in a typical Darktable workflow, it’s quite normal.

The biggest problem with this is that you assume AgX to be perfectly invert-able. But it’s not. You can indeed bake AgX out as a LUT, apply the LUT in reverse direction to get an Inverse AgX, but it won’t be a one-to-one round trip, you would end up with some bogus values with potential posterizations and clippings. It might work in some not so challenging cases, but it won’t work perfectly at all time. Inverting a picture formation is a hack anyways.

AgX attenuates chroma as the exposure increases, it will eventually arrive at the point of achromatic. How are you supposed to invert this process? Take an achromatic display pixel and turn it back to chromatic exposure?

I believe ACES 2.0 was an attempt to make a picture formation invert-able, but you should read Chris Brejon’s comment on the matter. It just doesn’t work well.

You can do that today. Export a picture of a color checker after AgX, and a camera JPEG. Put them both into darktable-chart, and it will create for you a style that transforms one into the other.

That’s what I’ve done here: Darktable-Film-Simulation-Panel/styles at master · bastibe/Darktable-Film-Simulation-Panel · GitHub, and it works very well.

Since most of our editing now happens before AgX/Sigmoid/Filmic, I find the LUT is better placed after, so as to not collide with my other edits.

2 Likes