Convert 3D LUT to hald image

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
graham768
Posts: 1
Joined: 2018-03-09T12:10:51-07:00
Authentication code: 1152

Re: Convert 3D LUT to hald image

Post by graham768 » 2018-03-09T12:23:16-07:00

I've found a solution on another forum. I used the GIMP plugin G'MIC from the command line. It's really simple to install on linux; I used homebrew on mac with

Code: Select all

brew install gmic

The script takes a LUT input (in my case .CUBE) and converts it directly to a Hald Clut PNG

Code: Select all

gmic -input_cube /path/to/lutfile.cube -r 64,64,64,3,3 -r 512,512,1,3,-1 -o haldclut_output.png
I created a quick and dirty script to take a directory of files and quickly give the PNG output.

VbNetMatrix
Posts: 1
Joined: 2018-04-08T07:32:30-07:00
Authentication code: 1152

Re: Convert 3D LUT to hald image

Post by VbNetMatrix » 2018-04-08T07:46:02-07:00

I'm glad you found a solution after so many years!

however, Since LUT are simply a MASK to a picture (apply bit per bit with a corresponding math function),
II believe 2D LUT (PNG) should be supported directly with image magick.

this would avoid us the trouble to load the image in photoshop to apply the LUT on image.
LUT are also used in direct feed camera for streaming (with OBS/Twitch/Youtube)

thanks for Image Magick though, great program.

snibgo
Posts: 10929
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert 3D LUT to hald image

Post by snibgo » 2018-04-08T08:33:48-07:00

ImageMagick supports both "2D" and "3D" luts, using "-clut" and "-hald-clut" respectively. However, IM needs the luts to be images, and doesn't support formats such as .CUBE.
snibgo's IM pages: im.snibgo.com

B4adle7
Posts: 3
Joined: 2018-06-10T10:25:40-07:00
Authentication code: 1152

Re: Convert 3D LUT to hald image

Post by B4adle7 » 2018-06-10T10:42:57-07:00

How can we make a feature request to support .cube and/or other basic 3D Lut data files? (.lut, .shlut, .3dl, .cube)

Currently ImageMagick supports other data files such as CDLs. However it currently only supports HALD files for LUT transforms.
In order to create the HALD files ImageMagick users need to use a separate software package, find a conversion script, or reverse engineer and write a converter.

I recall this subject has been brought up in other posts. I know FFMpeg supports .cube and other 3D Luts, I believe. And it may remove some of the HALD limitations, such as support for negative or over 100% values.

User avatar
fmw42
Posts: 24096
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert 3D LUT to hald image

Post by fmw42 » 2018-06-10T11:36:21-07:00

How can we make a feature request to support .cube and/or other basic 3D Lut data files? (.lut, .shlut, .3dl, .cube)
Post this same message to the Developer's forum.

snibgo
Posts: 10929
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert 3D LUT to hald image

Post by snibgo » 2018-06-10T11:44:24-07:00

B4adle7 wrote:How can we make a feature request to ...
Post to the Developers forum: http://www.imagemagick.org/discourse-se ... 1351dd23dd

To help the developers, you should include references to documentation on the formats you would like supported.

Ideally also suggest how IM will identify the format. If any of those formats are valid image formats, then a suffix (.lut etc) isn't sufficient.
B4adle7 wrote:And it may remove some of the HALD limitations, such as support for negative or over 100% values.
It already does, in the sense that if the hald-clut contains values outside 0 to 100%, those values will be used in output. However the input coordinates to the hald-clut correspond to input values of 0% at top-left to 100% at bottom-right. Do you want this to be more flexible? If so, please describe.
snibgo's IM pages: im.snibgo.com

B4adle7
Posts: 3
Joined: 2018-06-10T10:25:40-07:00
Authentication code: 1152

Re: Convert 3D LUT to hald image

Post by B4adle7 » 2018-11-24T22:38:28-07:00

Thank you for the responses, and forgive the delay in reply.
Yes I will post that to the developers forum.
If any of those formats are valid image formats, then a suffix (.lut etc) isn't sufficient.
Unsure of the note here, but just in case. .lut is a "Look Up Table". Same data as in a .cube, shlut, or .3dl file. Basically the non-image version of a HALD CLUT file. Since Imagemagick supports CDL files (.cdl, .cc) (Color Decision List), that are XML data files of color transforms, would think doing the same with their LUT counter-parts would be an of-course.

The second part of the response asks for a description. And to be fair have not had a breath to explore using .exr files and the full 32 bit HDR version of IM.
Commonly have used .png HALDs to do the color conversions of Log colorspace to linear or the desired sRGB/rec709 viewing colors.
However more and more often encounter instances where color transforms (LUT/CDL) are done oddly, or over-done, pushing colors over (1.0+) or under (negative) in one color transform, then back into acceptable range with another. (Think kids drawing outside the lines).
However in order to process the data and keep everything matched, the same is needed.
PNG does not support below 0 or above 1.0.
Also you bring up a good point, what if it is not just the color range that needs matched, but the range also.

The data formats mentioned are not images. Direct data to transform color values. They are usually simple ascii text files allowing for 1D and 3D color transforms. This is a link that mentions several of the commonly used ones.
https://kb.pomfort.com/livegrade/cdl_al ... or-export/

Thank again for the response. Will see about adding that to the developers post

User avatar
fmw42
Posts: 24096
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert 3D LUT to hald image

Post by fmw42 » 2018-11-24T23:12:53-07:00

1D cluts are images in ImageMagick. But you can create them as text values and import them via NetPMB image formats into 1D images of 1 or 3 channels. Hald-Luts in ImageMagick are 2D images. I know of no way to convert from text formats to Hald-Luts, currently in ImageMagick. In HDRI compiled ImageMagick, if you have values outside the Quantumrange for your compile, you can use TIFF or PFM formats to store images that go outside the range such as negatives and fractions. Perhaps one of the other users have more to contribute her than I.

Post Reply