Bake a Color Transform

Problem

You have an image file with an Alexa LogC LUT. You want to bake the Alexa LUT to prepare the files for display.

Solution

Use the Draft.LUT class:

import Draft

inFile = '/path/to/input.exr'
outFile = '/path/to/output.exr'

img = Draft.Image.ReadFromFile( inFile )

lut = Draft.LUT.CreateAlexaV3LogC().Inverse()
lut.Apply( img )

img.WriteToFile( outFile )

Discussion

To create the LUT, we call Draft.LUT.CreateAlexaV3LogC(). The resulting LUT will convert an image from Linear to Alexa V3 Log C. This is the opposite of what we want, so we use the Inverse() method. This method returns a new LUT that will convert an image from Alexa V3 Log C to Linear, which is what we need.

We apply the LUT to the image:

lut.Apply( img )

before we WriteToFile().

Draft includes several LUTs in addition to Alexa V3 Log C:

LUT Draft command
Cineon Draft.LUT.CreateCineon()
Alexa V3 Log C Draft.LUT.CreateAlexaV3LogC()
sRGB Draft.LUT.CreateSRGB()
Rec. 709 Draft.LUT.CreateRec709()
Gamma correction Draft.LUT.CreateGamma()

See Also

For the applying a Color Transform please review Convert a QuickTime’s Color Space.