< Previous | Contents | Next >

Color Matrix

Color Matrix uses a 4x4 matrix like 3D to manipulate color of an image, This can be used for linear operations like Brightness, Contrast, Gain and RGB-YUV conversion.

--********** Color Matrix*********

local cm = ColorMatrixFull() -- Create a color matrix

--Apply Brightness to the matrix via Offset function

cm:Offset(0.1, 0.1, 0.1, 0) -- RGBA values adding 0.1 to RGB and 0 to Alpha

--Scale is the same as Gain which will multiply the Matrix by 1.1 cm:Scale(1.1, 1.1, 1.1, 1.1) -- Multiplies RGBA by 1.1 like Gain

--Applies the Color Matrix (cm) on image (img) outputting to another image (out)

out = img:ApplyMatrixOf(cm, {})