Giter Site home page Giter Site logo

cglut's Introduction

cglut

Create your own color-grading 3D-LUT preset using a custom python script.

Huge improvement over DomBito/muhcolors.

What you can do with it

  • White-balance by just inputing RGB values for which you want the saturation to be zero.
  • RGB curves function that accepts GIMP preset files (in the old format) as input.
  • 1-D Curve function, but with extra channel options such as luminance, lightness, chroma and even hue.
  • Powerful "perturb" function, which is perturbation of the identity map of one channel, where the perturbation added is a function of another given channel.
  • Tweak function similar to AviSynth's Tweak.
  • Use of visually uniform and linear color-spaces, such as XYZ, xYy, cieLUV, cieLch and hsluv. For that, most of the hsluv project conversions are re-implemented in NumPy, so it's optimized for arrays.

More details on how the functions work and how to use them in the future.

Usage:

usage: cglut [-h] [-s LSIZE] [-o LUTFILE] [-c] script_file

Script-based color-grading 3D LUT creator.

positional arguments:
  script_file           script file with the color-grading functions

options:
  -h, --help            show this help message and exit
  -s LSIZE, --lut_size LSIZE
                        set LUT size (32, 64, 128, or 256)
  -o LUTFILE, --output LUTFILE
                        Name of the lut file.
  -c, --clean           Doesn't save the preLUT file (preLUT makes consecutive exports faster).

Running cglut on a script will export a file named lut.cube.

Example of a custom script:

#your_script_file.py
gray_points= [[10,11,6], [150,144,149], [235,215,244]]
balance(gray_points)
rgbcurve(red=[0,0,100,70],green=[0,0,100,100],blue=[0,20,100,90], mode='luminance',strength=0.9)
tweak(hue=10, l_range=[30,80], c_range[50,100], h_range=[180,210], smooth=30)

What this example script does:

  • Applies white-balance by shifting the chroma channels along the luminosity so the gray_points turns into actual grays (zero saturation).
  • Change the scale of each Red, Green, and Blue channels using curve-like function (with linear interpolation). In this instance, it only affects the luminosity (mode='luminance') and it takes 90% of effect (strength=0.9) of what this particular RGB curve would normally do.
  • Adds 10 deg of hue for the colors within the given lightness, chroma and hue ranges. Outside this range, the strength of the filter linearely drops to 0 when the colors are 30 numbers alway from the ranges in each channel (smooth=30).

Using the exported LUT:

You can import the .cube file in any program that accepts this format. However, this is a project made with vapoursynth in mind. You can import the LUT file using sekrit-twc/timecube as follows:

# In this example, src is a YUV420P8, rec709 videonode.
dst = core.resize.Bicubic(clip=src, format=vs.RGBS)
dst = core.timecube.Cube(dst,cube="lut.cube")
dst = core.resize.Bicubic(clip=dst, format=vs.YUV420P8, matrix_s='709')

Using ffmpeg to apply the LUT:

To get an image or video with your LUT applied to it withFFmpeg, you just need to run

ffmpeg -y -v quiet -i VIDEO_OR_IMAGE_INPUT -vf lut3d="CUBE_FILE" VIDEO_OR_IMAGE_INPUT

Preview with MPV:

You can quickly preview the LUT file on a image or video using mpv:

mpv --keep-open --vf="lavfi=[lut3d=CUBE_FILE]" VIDEO_OR_IMAGE_FILE

Applying it with Imagemagick

For images only, you can also use ImageMagick:

magick IMG_INPUT cube:CUBE_FILE -hald-clut IMG_OUTPUT

cglut's People

Contributors

dombito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ai2ys

cglut's Issues

Real-ish-time control

Excited to try this.
How fast is LUT generation?

Any way to bypass LUT gen and run pixels through the color pipelines directly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.