Create and save LUT/CLUT for use in video editing

Hi. Is it possible with G’MIC to create a LUT from a single source/reference image and then save that LUT in a format such as .cube or similar that can be used in video editing software? I see several LUT/CLUT filters in G’MIC but being pretty new to G’MIC, I haven’t really figured out a way to create a LUT from a single image and then save that LUT out to a format that can be imported into a video editing software. Is there a way to do this? Thanks.

If you use HaldCLUT, you can run the identity PNG file though GMIC and get a usable haldclut.

@paperdigits Thanks. How would I do that? I think using the ‘Transfer Colors’ filter, I can get a LUT from an image. But I’m not sure about the running the identity PNG file through G’MIC to get a usable HaldCLUT bit :slight_smile:

You download the HaldCLUT identity image, then open that file in gmic. Run any color type of filter you want on it, then save the result. The result image is your clut that you can load elsewhere.

1 Like

@spinblade if you have already a final version you can also create the HaldCLUT with the filter CLUT from After - Before Layers.

When I need to use the LUT in a different tool I transform my gmic HaldCluts into .cube file with Iwltbap LUT Generator

3 Likes

This question interests me because I have been trying to improve my color toning in my photos. For this, I use a variety of techniques in RawTherapee and the GIMP, depending on the situation, what I want to do specifically, and how much time I want to spend on it.

I also sometimes edit videos in Kdenlive and have started to do some color grading there, also. It would be great if I could grab a frame from a video that I’m working on, color grade it in RawTherapee (since I’m most familiar with that), then generate a LUT using G’Mic / Gimp. RT is nice also because I can color grade the frame grab to my liking, then apply the same color corrections to the HaldCLUT identity image that @paperdigits linked above by applying the PP3 from the graded frame grab.

That’s the background. Now the good part…

Kdenlive’s documentation is pretty crappy. But it does have an effect called “apply LUT.” I messed around with it, and it wants me to provide a file of type: *.cube, *.3dl, *.dat or *.m3d.

So the question: once I generate a LUT with GMIC, I guess I would save it as a PNG. Where do I take it from there to make one of those filetypes that Kdenlive will accept? @Hebustetram linked to an app that will do it, but I would like something for Linux, or maybe a web-based service.

Any ideas, or comments on my process so far?

I did do a test with RT and the identity image, but could not get to the end because I don’t have the proper file type (*.cube, *.3dl, *.dat or *.m3d)

I would also suggest the use of the filter CLUT from After / Before layers, which has been specifically designed to construct CLUTs from a pair of images.
If needed, I can add an option to save the generated CLUTs as a .cube file. G’MIC is already able to load/save .cube files, so it should not be a big deal to add that option.

5 Likes

For linux, the iwltbap LUT converter works with WINE

This using kubuntu 18.04 Things to look out for. Screenshots - in pairs

Using CLUT from After-Before - set it to new image for ease of use. Export to png in Gimp with zero compresion. https://i.imgur.com/iSwUNh8.jpg

Set the iwltbap LUT generator to Win7 in winecfg The generated .cube file which is just a text file. https://i.imgur.com/MGQfBXa.jpg

David - thanks for the reply. Yes, when I was experimenting with Gmic, that is what I used - the CLUT from After / Before layers. Adding the option to output a .cube file would be great, and would enable me to use it easily in kdenlive, I think. Assuming the Kdenlive “apply CLUT” effect does what it looks like it’s supposed to do.

I see below that there’s another app that works with Wine, but I don’t even have Wine set up, and if G’Mic could generate a .cube then that is one less application in the pipeline.

@David_Tschumperle Thanks. Yes, the option to save/export a .cube file within the LUT/CLUT filters would be great. Saving/exporting to .cube from within ‘Transfer Colors [Patch-Based]’, for example, would be perfect for me.

@Hebustetram Thanks. I discovered that iwltbap generator too! I downloaded it and it might be helpful for me.

I’ll be able to do this for the After / Before filter only. I’ll have a look at it next week. I’ll be in Lille for a conference, so don’t expect too much from me :slight_smile:

1 Like

Okay. Cool.

Here is my first attempt in improving the CLUT from Before / After Layers filter.
I’ve pushed the update, so it should be available for you, if you use G’MIC 2.7.0+ and if you press the ‘filter update’ button.

  • I’ve added a more sophisticated visualization of the estimated CLUT (3D rendering).
  • I’ve added an Output mode parameter, so that the user can choose saving the estimated CLUT as a .png or .cube file rather than having the CLUT inserted as a new layer.

That was quite a lot of work, so I hope this will be useful additions :slight_smile: Let me know what you think about it.

4 Likes

The filter does what it is supposed to do. Thank you again David.

1 Like

@David_Tschumperle That is excellent. This will be a big hit with people who use GIMP and also do video work. There aren’t too many utilities for this type of thing. The 3D output cube is also great :slight_smile: Thanks. Good update.

1 Like

I just had my first successful test with this filter.

I opened the video clip in VLC, took a snapshot / framegrab.

Then I used GIMP to fuss with the colors. Once I liked them, then I used the G’Mic before/after layer to generate a cube file.

I was then able to use that cube file in Kdenlive using their “apply LUT” effect.

One thing to note is that the first time I tried this, I increased the “output CLUT resolution.” When I used the resulting cube in Kdenlive, it had no effect on the picture quality.

I also tried to recreate the color from the CLUT by going to the original image in GIMP and using the G’MIC “apply external CLUT” filter with that high-resolution cube file. It took a long time ate all my RAM, and just resulted in a black screen.

But the output resolution of 64 worked OK in kdenlive (I didn’t test in gimp/g’mic).

Finally, G’MIC kept throwing me cryptic errors until I removed the space from the filename of the cube file. I think you should note that cubefiles cannot have a space in the filename.

But now that I know how this thing works, it will take my video to the next level.

thanks, David!!!

1 Like

That’s not expected :frowning:
Are you OK to share your .cube file somewhere, so I can test and see what is going on ?

That’s interesting, I think I can fix that too !

1 Like

It has been fixed. My fault.

Anyway, about the .cube format : it is a simple text file that stores all values of a CLUT, which means it becomes really big when the CLUT resolution is large.
I’ve actually never seen .cube files with a resolution higher than 45, most of them was more like 17^3, which is really tiny.

in other words: it’s a rotten file format, and it’s a shame it’s used as a kind of ‘standard’ for the distribution of CLUTs. If you use .cube files, I really suggest lowering the resolution to 25 to keep the file having a reasonable size.

1 Like

33x33x33 is more the norm.