< Previous | Contents | Next >
Process Event Function
The Process Event function is where the image processing operations occur and is executed whenever Fusion asks the fuse tool to render a frame. Fusion’s renderer will pass the Process function a single argument, an object called the Request. This argument contains all the information the tool needs
to know about the current render environment. The image.at the current time and the Controls like sliders at the current time.
The following Process example, will get an image and assign it to a Variable ’img’, it also gets three values from the sliders in the Inspector Tool controls and assigns them to variables ‘bright’, ‘contrast’,
‘sat’. It creates local variables ‘r’,’g’,’b’,’a’ and also creates a Color Matrix ‘m’. Internal functions are used to manipulate the matrix and then runs the function ApplyMatrixOf to the image, outputting to a destination image, then finally sets the resulting image to the fuse tools output.

function Process(req)
-- Get values from the UI Tools local img = InImage:GetValue(req)
local bright = InBright:GetValue(req).Value
local contrast = InContrast:GetValue(req).Value + 1 local sat = InSaturation:GetValue(req).Value
-- Define a set of variables local r = 0
local g = 0 local b = 0 local a = 0
if bright == 0 and sat == 1.0 and contrast == 1.0 then
-- no change, go ahead and bypass this tool OutImage:Set(req, img)
else
-- create a color matrix local m = ColorMatrixFull()
--Apply Brightness to the matrix via Offset function r = bright
g = bright b = bright
m:Offset(r, g, b, a)
--Apply Contrast by offsetting the color to the midpoint 0.5 r = contrast
g = contrast b= contrast a = 1
m:Offset(-0.5, -0.5, -0.5, -0.5)
m:Scale(r, g, b, a) m:Offset(0.5, 0.5, 0.5, 0.5)
--Apply Saturation by converting the Color Matrix to YUV and Scaling the Chroma UV channels
m:RGBtoYUV()
m:Scale(1, sat, sat, 1) m:YUVtoRGB()
end
end
--Apply the Color Matrix to the image img to output image out out = img:ApplyMatrixOf(m, {})
--Output the image OutImage:Set(req, out)