Search code examples
pythonimage-processinglookup-tables

Apply 3D Luts .cube files into an image using Python


I'm searching for a way to do this, I have looked at OpenCV but at least I could find only ways to apply 1D Luts files with it (256 long). Does anyone knows how to apply 3D Luts (64x64x64) to an image using python? thanks.


Solution

  • This worked for me.

    $ pip install pillow pillow-lut
    

    And then using a random .cube file from an Adobe Photoshop installation:

    from PIL import Image
    from pillow_lut import load_cube_file
    
    lut = load_cube_file("NightFromDay.CUBE")
    im = Image.open("image.png")
    im.filter(lut).save("image-with-lut-applied.png")