X-Git-Url: http://users.mur.at/ms/git/gitweb/?p=OpenColorIO-Configs.git;a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2FcreateARRIColorSpaces.py;h=3f5591cefd77c6c9cfa9f6be2c0f3405d98030e2;hp=0c153187b2811017f4f96e0de831fe0cf62b870e;hb=8a160c48f21fd063b5a59e702a9d5ffdaaefe3b3;hpb=4522d8db6373342fe8eddc5eb97e13322a9e80a3 diff --git a/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py b/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py index 0c15318..3f5591c 100644 --- a/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py +++ b/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py @@ -11,7 +11,12 @@ from aces_ocio.util import ColorSpace, mat44FromMat33 # # LogC to ACES # -def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResolution1d): +def createLogC(gamut, + transferFunction, + exposureIndex, + name, + lutDir, + lutResolution1d): name = "%s (EI%s) - %s" % (transferFunction, exposureIndex, gamut) if transferFunction == "": name = "Linear - %s" % gamut @@ -22,7 +27,7 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti cs.description = name cs.equalityGroup = '' cs.family = 'ARRI' - cs.isData=False + cs.isData = False # Globals IDT_maker_version = "0.08" @@ -33,10 +38,11 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti encodingGain = 0.256598 encodingOffset = 0.391007 - def gainForEI(EI) : - return (math.log(EI/nominalEI)/math.log(2) * (0.89 - 1) / 3 + 1) * encodingGain + def gainForEI(EI): + return (math.log(EI / nominalEI) / math.log(2) * ( + 0.89 - 1) / 3 + 1) * encodingGain - def LogCInverseParametersForEI(EI) : + def LogCInverseParametersForEI(EI): cut = 1.0 / 9.0 slope = 1.0 / (cut * math.log(10)) offset = math.log10(cut) - slope * cut @@ -45,7 +51,7 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti # The higher the EI, the lower the gamma encGain = gainForEI(EI) encOffset = encodingOffset - for i in range(0,3) : + for i in range(0, 3): nz = ((95.0 / 1023.0 - encOffset) / encGain - offset) / slope encOffset = encodingOffset - math.log10(1 + nz) * encGain # Calculate some intermediate values @@ -60,23 +66,24 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti a = a * s f = f + e * t e = e * s - return { 'a' : a, - 'b' : b, - 'cut' : (cut - b) / a, - 'c' : encGain, - 'd' : encOffset, - 'e' : e, - 'f' : f } + return {'a': a, + 'b': b, + 'cut': (cut - b) / a, + 'c': encGain, + 'd': encOffset, + 'e': e, + 'f': f} def logCtoLinear(codeValue, exposureIndex): p = LogCInverseParametersForEI(exposureIndex) breakpoint = p['e'] * p['cut'] + p['f'] if (codeValue > breakpoint): - linear = (pow(10,(codeValue/1023.0 - p['d']) / p['c']) - p['b']) / p['a'] + linear = ((pow(10, (codeValue / 1023.0 - p['d']) / p['c']) - + p['b']) / p['a']) else: - linear = (codeValue/1023.0 - p['f']) / p['e'] + linear = (codeValue / 1023.0 - p['f']) / p['e'] - #print( codeValue, linear ) + # print(codeValue, linear) return linear @@ -85,56 +92,69 @@ def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResoluti if transferFunction == "V3 LogC": data = array.array('f', "\0" * lutResolution1d * 4) for c in range(lutResolution1d): - data[c] = logCtoLinear(1023.0*c/(lutResolution1d-1), int(exposureIndex)) + data[c] = logCtoLinear(1023.0 * c / (lutResolution1d - 1), + int(exposureIndex)) - lut = "%s_to_linear.spi1d" % ("%s_%s" % (transferFunction, exposureIndex)) + lut = "%s_to_linear.spi1d" % ( + "%s_%s" % (transferFunction, exposureIndex)) # Remove spaces and parentheses lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_') - genlut.writeSPI1D(lutDir + "/" + lut, 0.0, 1.0, data, lutResolution1d, 1) - - #print( "Writing %s" % lut) - cs.toReferenceTransforms.append( { - 'type':'lutFile', - 'path':lut, - 'interpolation':'linear', - 'direction':'forward' - } ) + genlut.writeSPI1D(lutDir + "/" + lut, + 0.0, + 1.0, + data, + lutResolution1d, + 1) + + # print("Writing %s" % lut) + cs.toReferenceTransforms.append({ + 'type': 'lutFile', + 'path': lut, + 'interpolation': 'linear', + 'direction': 'forward' + }) if gamut == 'Wide Gamut': - cs.toReferenceTransforms.append( { - 'type':'matrix', - 'matrix':mat44FromMat33([0.680206, 0.236137, 0.083658, - 0.085415, 1.017471, -0.102886, - 0.002057, -0.062563, 1.060506]), - 'direction':'forward' + cs.toReferenceTransforms.append({ + 'type': 'matrix', + 'matrix': mat44FromMat33([0.680206, 0.236137, 0.083658, + 0.085415, 1.017471, -0.102886, + 0.002057, -0.062563, 1.060506]), + 'direction': 'forward' }) cs.fromReferenceTransforms = [] return cs + def createColorSpaces(lutDir, lutResolution1d): colorspaces = [] transferFunction = "V3 LogC" gamut = "Wide Gamut" - #EIs = [160.0, 200.0, 250.0, 320.0, 400.0, 500.0, 640.0, 800.0, 1000.0, 1280.0, 1600.0, 2000.0, 2560.0, 3200.0] - EIs = [160, 200, 250, 320, 400, 500, 640, 800, 1000, 1280, 1600, 2000, 2560, 3200] + # EIs = [160.0, 200.0, 250.0, 320.0, 400.0, 500.0, 640.0, 800.0, + # 1000.0, 1280.0, 1600.0, 2000.0, 2560.0, 3200.0] + EIs = [160, 200, 250, 320, 400, 500, 640, 800, + 1000, 1280, 1600, 2000, 2560, 3200] defaultEI = 800 # Full conversion for EI in EIs: - LogCEIfull = createLogC(gamut, transferFunction, EI, "LogC", lutDir, lutResolution1d) + LogCEIfull = createLogC( + gamut, transferFunction, EI, "LogC", lutDir, lutResolution1d) colorspaces.append(LogCEIfull) # Linearization only for EI in [800]: - LogCEIlinearization = createLogC("", transferFunction, EI, "LogC", lutDir, lutResolution1d) + LogCEIlinearization = createLogC( + "", transferFunction, EI, "LogC", lutDir, lutResolution1d) colorspaces.append(LogCEIlinearization) # Primaries - LogCEIprimaries = createLogC(gamut, "", defaultEI, "LogC", lutDir, lutResolution1d) + LogCEIprimaries = createLogC( + gamut, "", defaultEI, "LogC", lutDir, lutResolution1d) colorspaces.append(LogCEIprimaries) return colorspaces