Skip to content

Instantly share code, notes, and snippets.

@cyfdecyf
Created December 21, 2023 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyfdecyf/f1daf4ead3e54c4b50d2e0a837860ece to your computer and use it in GitHub Desktop.
Save cyfdecyf/f1daf4ead3e54c4b50d2e0a837860ece to your computer and use it in GitHub Desktop.
Generate 3D LUT
#!/usr/bin/env python
class Lut3DGenerator:
def __init__(self):
pass
def gen_identity_3dlut(self, lut_size, output_fname):
lut_size_f = float(lut_size)
# Generate an identity 3D LUT and write to output file.
with open(output_fname, 'w') as f:
f.write('TITLE "Identity 3D LUT"\n')
f.write('LUT_3D_SIZE {}\n\n'.format(lut_size))
for b in range(lut_size):
for g in range(lut_size):
for r in range(lut_size):
f.write('{} {} {}\n'.format(r / lut_size_f, g / lut_size_f, b / lut_size_f))
if __name__ == '__main__':
Lut3DGenerator().gen_identity_3dlut(33, 'identity_33.cube')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment