HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/resolve/Developer/Fusion Fuse/Example 1 Bright Contrast.fuse
--[[--
Example Fuse 1
This uses internal Fusion Color and Corlor Matrix operations to change the color of images.


Copyright (c) 1988-2020, BMD, by Steve Roberts
This Fuse Demos built in image processing functions in Fusion.


This Uses Fusion internal image processing operations:
Color Matrix is similar to 3D matrix operation and applied to the color of an image.
This will apply Brightness, Contrast and Saturation to images

--]]--
--******************************************************************************************************
-- This Registers the Fuse into Fusion, gives its Name, and Menu location. Location of Help. Can Fuse be edited.
FuRegisterClass("ExampleBrightContrast", CT_Tool, {
	REGS_Name          = "Ex1 Bright Contrast",
	REGS_Category      = "Fuses\\Examples",
	REGS_OpIconString  = "E1BC",
	REGS_OpDescription = "Example using internal Color Matrix image processing functions ",
	REGS_HelpTopic     = "Example Location of Help", --This can be a URL
	REGS_URL           = "www.blackmagicdesign.com",
	--REGS_IconID = "Icons.Tools.Icons.Example",-- This can be Inline as an array of Values
	REG_OpNoMask       = false,
	REG_NoBlendCtrls   = false,
	REG_NoObjMatCtrls  = false,
	REG_NoMotionBlurCtrls = true,
	REG_Fuse_NoEdit    = false,
	REG_Fuse_NoReload  = false,
	REG_Version        = 1, 
}) -- End of RegisterClass

--****************************************************************************************************
--Create will define all the controls, like sliders, check boxes, onscreen crosshairs etc, that will show in Inspector Tool control area

function Create()
		
	InBright = self:AddInput("Brightness", "Brightness", {
		LINKID_DataType    = "Number",
		INPID_InputControl = "SliderControl",
		INP_MaxScale       = 1.0,
		INP_MinScale       = -1.0,
		INP_Default        = 0.0,
		})

	InContrast = self:AddInput("Contrast", "Contrast", {
		LINKID_DataType    = "Number",
		INPID_InputControl = "SliderControl",
		INP_MaxScale       = 1.0,
		INP_MinScale       = -1.0,
		INP_Default        = 0.0,
		})
		
	InSaturation = self:AddInput("Saturation", "Saturation", {
		LINKID_DataType    = "Number",
		INPID_InputControl = "SliderControl",
		INP_MaxScale       = 5.0,
		INP_MinScale       = 0.0,
		INP_Default        = 1.0,
		ICD_Center         = 1,
		})
	
	InImage = self:AddInput("Input", "Input", {
		LINKID_DataType = "Image",
		LINK_Main       = 1,
		})
 
	OutImage = self:AddOutput("Output", "Output", {
		LINKID_DataType = "Image",
		LINK_Main       = 1,
		})	
 
end -- end of Create()

--*************************************************************************************************************
-- The Process section is the main section where the image processing rendering occurs

function Process(req)
	local img      = InImage:GetValue(req)
	local bright   = InBright:GetValue(req).Value
	local contrast = InContrast:GetValue(req).Value + 1
	local sat      = InSaturation:GetValue(req).Value
	
	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 0.5 color midpoint to 0.0, scaling around that, and offsetting back again
		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) -- scale U and V chroma channels, leave Y luma channel alone
		m:YUVtoRGB()
	
--Apply the Color Matrix to the image img into the output image out		
		out = img:ApplyMatrixOf(m, {})

--Output the image 		
		OutImage:Set(req, out)
	end
end