HaldCLUT module in darktable

I’ve been using @patdavid’s film emulation pack for a while, and as a darktable user I’ve always found the round-trip between darktable, GIMP and G’MIC to be rather lengthy (compared to Rawtherapee and others developers that fully integrate the process into the pipeline). So with the recent discussion of LUTs and despite the introduction of the “color checker lut” module in darktable, I still decided to implement a Hald CLUT module. This way I can see the final effect in live action.

Here is what it looks like right now:


(Applying @patdavid’s Fuji Superia 400 emulation on the left)

Some things of note:

  • It basically takes a path to the LUT and applies that, you can tweak the strength of the effect with darktable’s blending modes.
  • It only supports LUTs in PNG format currently.
  • The LUT is applied very late in the pipeline (after output color profile).
  • Currently it only stores the file path but not the actual LUT in the sidecar, so sharing the sidecar across users can be problematic.

I will clean up the code and post the source later in case someone wants to play with it. :slight_smile:

8 Likes

Ok. I have pushed the source to the haldclut branch of my repository on GitHub. You can clone the source here, build and play with it.

Let me know if you find out ways to break it. :smiley:

Looking promising! I really miss film emulation in darktable, I even started to create my own set of tone curves to match pat’s definitions on some of my favorite films. So I’m very curious to see where these LUT updates on darktable can go.

I don’t have that much spare time, but if I can find some i’ll clone it that and give it a go. :+1:

This is really cool! Yes, film emulation is one if the main missing things from DT, so I’m really glad to see you proceed with this. I will test as soon as I can - in the middle if a move tight now, but should be set up again soon (internet is being installed in my new place today! I can be civilised again!)… I will indeed let you know if I find a way to break it! :smile:

@PkmX I don’t know about the current speed of your implementation but as you use almost the same code we used before our speedups I would suggest you may take a look here in case you want to use a vectorized version without reinventing the wheel :wink:

2 Likes

@t3mujin @Isaac Thanks!

@heckflosse Awesome! I will look into it!

I just ran a test export on a 24MP image and it took about 0.3 seconds on a i7-2600 (4 cores with 8 threads):

[dev_pixelpipe] took 0.302 secs (1.707 CPU) processed `hald clut' on CPU, blended on CPU [export]

As a point of reference, both profiled denoise and equalizer take ~6 secs on CPU and ~1.5 secs on GTX 960, so it is not too bad currently. In darkroom it is pretty much instant.

Interesting and possibly quite handy although putting it after color output module does mean you are limited there since a CLUT will also have a color space[1] so I think for most of Pat David’s CLUTs output must be set to prohoto (since IIRC rawtherapee uses prophoto primaries internally).

For darktable it would be neater if we could have CLUTs in LAB color space (or convert it to LAB[2] on load) in that case the module can be put before color output and be much more generic (theoretically)

footnotes

[1] Actually might have 2 color space, one input and one output (for example sRGB to ProphotoRGB (inverse) transform might be expressed as a CLUT) this property is actually used in openColorIO (there colorspace are defined in terms of transforms to and from a reference space and most of those transforms are described as CLUTs)
[2] Since we are talking about look CLUTs both the input and output need to be converted of course

@dutch_wolf rawtherapee uses whatever colour space you choose internally and takes care of the conversions when clut is in a different colour space.

1 Like

@heckflosse thanks for the info not that much experience with Rawtherapee a Darktable user myself

@dutch_wolf Currently, the module just assumes that the input is in the same color space of the CLUT (and bad things will happen if it is not) since it doesn’t perform any conversion. I put the module very late in the pipeline as it was closest to what I have been doing (exporting from darktable and then grading it in G’MIC), and it would be the easiest way to implement (as someone who is still getting around darktable’s codebase). During testing I did found a few cases of out-of-gamut lookup, so I guess I will try to convert both to Lab* and see how it goes.

Rawpedia says that those are in sRGB, are they not?

IIRC they are in sRGB! But you can also create HaldCluts in a different colour space which means I wouldn’t rely on being them sRGB

@PkmX if the docs say they are in sRGB then I assumed wrong (assumptions are the mother of all ***** ups :wink: ) anyway as @heckflosse says CLUTs (including HaldCLUTs) can be in any color space so best to future proof that anyway

Hello, excuse me for my English, I made a translation online. I compiled with the branch HaldCLUT I find very good. I had the opportunity to use the profiles with RawTherapee. Est’il possible that it is integrated into a future version of darktable. I compile the GitHub version and it is not there? Good week, cordially.
P.S. sorry for the message yesterday suppimer. I thought it was in French.

AFAIK this is not an official update so is not available via the official github the designers are working on another CLUT module that should be able to import these HaldCLUTs but which is also easier to edit from within Darktable and can be saved inside the xmp sidecars. See more here: colour manipulation with the colour checker lut module | darktable (I made a video about how to import C’Mig provided CLUTs but that is I think already outdated)

1 Like

Thank you for your reply. Cordially.