GIMP - How to apply 3D LUT?

Hey

I need to apply a 3D LUT to a layer in GIMP, how do I do that?
Can it be done via ICC or HaldCLUT?

Possibly using Gā€™MIC? Could you export the layer and apply the HaldCLUT directly using something like imagemagick? (Is the CLUT already in a HaldCLUT form?)

Yes, that is something that could be done in Gā€™MIC, with the filter Film emulation / User-defined.
See screenshot below:

Here, Iā€™ve chosen a HaldCLUT as a .png file, get from : http://gmic.eu/film_emulation/negative_old/clut/fuji_superia_100_+.png

but this should work with other CLUT files.

PS: Iā€™ve also updated the filter today, to make it handle 16bits/channels CLUT files, so donā€™t forget to press the update button before using it :slight_smile:

2 Likes

Does the CLUT have to be in a HaldCLUT form?

The 3D LUT can be in whatever format Photoshop can export it in. Thing is I donā€™t have Photoshop so I donā€™t know what formats those might be. If one of you, or someone reading this, does have access to PS, could you check? Then weā€™d know what our options are for using PS 3D LUTs in GIMP, Gā€™MIC or other libre software.

@Morgan_Hardwood I have PS CS6 (Win 7, 64-bit). What would you like me to check?

@Claes there is an option to apply a 3D LUT, could you check two things?

  1. What file formats are accepted as input for 3D LUTs?
  2. What file formats can you save/export the 3D LUTs in?

@Morgan_Hardwood

I can use 3D LUTs in my PS CS6 version, and it looks like

  • 3DL
  • CUBE
  • CSP
  • look
    formats are allowed.

However, I cannot export 3D LUTs, exporting was introduced in the PS CC 2014 release. You will find more information here: Export color lookup tables from Photoshop

OK?

Thanks @Claes!
Iā€™m not familiar with those formats - if someone has sample files, please upload!

Ideally, GIMP should support applying a 3D LUT to a layer in whatever format is popular.
For now, we need to find and document the easiest way of being able to use a 3D LUT from PS (or from the world at large) in GIMP. That could mean converting one of those formats you listed into something GIMP/Gā€™MIC can use (what can they use other than HaldCLUT? @David_Tschumperle?), or it could mean creating a HaldCLUT which has the same effect as those PS-compatible 3D LUTs have.

The only difficulty I found when dealing with HaldCLUTs is the gamma curve - itā€™s not always clear what to use.
Here Film Simulation - RawPedia I documented how to create a HaldCLUT using ImageMagick and then how to hack-create a DNG file for use as a HaldCLUT.

Step by step, we would need to:

  1. Get our hands on some 3D LUTs in 3DL, CUBE, CSP or ICC (is that ā€œlookā€?) formats,
  2. Apply them to a publicly available test image.
    I recommend this one, just because it has a wide range of colors and I shot it so no licencing issues:
    http://rawtherapee.com/shared/test_images/colorspace_flowers.pef
    Ideally save that as a 16-bit 900px-wide TIFF (no need for a large image, keep it small), then apply those 3D LUTs in PS, and save the resulting images as 16-bit TIFFs.
  3. Apply the same 3D LUTs to a HaldCLUT identity fileā€¦ or actually to two HaldCLUT files: one created using
    -colorspace sRGB, and the other using
    -colorspace RGB, as described in the RawPedia link, because we donā€™t know which one will work correctly.
  4. Upload the 3D LUTs + the original and processed photo TIFF + the original and processed HaldCLUT TIFFs
  5. We find out which combination leads to the same results, document it, ?, profit.

You can get a free Photoshop trial version from Adobe:

@Morgan_Hardwood
Two clues found:
3dl file specification

Cube lut specification

I started writing some LUT code for darktable a while ago and used these LUTs for testing: http://luts.iwltbap.com/#freeware. Those are CUBE files which are really easy to parse and process, the specs are here: http://wwwimages.adobe.com/content/dam/Adobe/en/products/speedgrade/cc/pdfs/cube-lut-specification-1.0.pdf.

If there is need for a simple tool that takes such a CUBE file and applies it to an image (or maybe even just creates a HaldCLUT) then ping me, I could probably turn my local test code into something useful.

1 Like

The Cube format seems to be a simple text file, should be easy to parse indeed. Iā€™ll try maybe to add a Gā€™MIC command to convert them into HaldCLUT.
By the way, when I see the size of a single CLUT file of 5Mb (zipped), ouch that hurts !
Good to know that we donā€™t use this format in Gā€™MIC to store the 300+ HaldCLUT we have :slight_smile:

1 Like

I have recently being pointed to the OpenColorIO project, which is licensed under BSD and has support for a large number of LUT formats.

Iā€™m still trying to understand all the functionalities offered by this library, and in particular how to insert it into ICC-based color-managed workflows, but it might be a good option to avoid coding the support for several LUT formats from scratch.

I found this but forgot to paste the link in the previous post:
http://opensource.mikrosimage.eu/ColorPipe-tools/LUTLab/LUT_to_LUT/

1 Like

I wouldnā€™t spend too much time on that. OpenColorIO is the movie industryā€™s competitor to an ICC workflow. In theory it might be possible to make the two work together, but in the real world itā€™s an either-or choice.

Being able to directly convert a format like Cube into HaldCLUT would be awesome!

Well, Iā€™ve done a small test with one file found from the link @houz provided, and Iā€™ve been able to import the CLUT data into Gā€™MIC. That was a ā€˜manualā€™ attempt, so with head -n and tail -n to manipulate the .cube (text) file, but this worked. Iā€™m pretty sure I can add at least a command that will be able to import some .cube files.

Ok, so here is a first attempt. Refresh your filters in the Gā€™MIC plug-in for GIMP, and try to provide a .cube file to the Film Emulation / User-defined filter, like this :

And do not expect it to work :slight_smile:
This is something Iā€™ve hacked in 20 minutes, so the chances it works for all .cube files is very low.
Of course, if it doesnā€™t work as expected, please tell me, eventually send me the corresponding .cube file for inspection.

2 Likes

Salut! Tested with The Gimp 2.9.3 and gā€™mic 1.7.2.
Updated User-Defined Film emulation (got Latest update 06/11/2016). Tested a cube from PS6. Result:
Preview warning: Specified Hald-CLUT filename not found.