Code:
--[[-- This Fuse is my first attempt to create a High/Low Probe stand alone Fuse in Fusion
--]]--
FuRegisterClass("HighLowProbe", CT_Tool, {
REGS_Name = "High Low Probe Tool",
REGS_Category = "Fuses\\eyeon",
REGS_OpIconString = "Prb",
REGS_OpDescription = "This tool searches a image sequence and returns the highest and lowest values in the red channel.",
REG_NoAutoProxy = true,
REG_OpNoMask = true,
REG_NoBlendCtrls = true,
REG_NoMotionBlurCtrls = true,})
function Create()
InImage = self:AddInput("Input", "Input", {
LINKID_DataType = "Image",
LINK_Main = 1,
})
InChannel = self:AddInput("Channel", "Channel", {
LINKID_DataType = "Number",
INPID_InputControl = "MultiButtonControl",
INP_Default = 0.0,
{ MBTNC_AddButton = "Red", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Green", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Blue", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Alpha", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Luma", MBTNCD_ButtonWidth = 1/5, },
INP_Integer = true,
})
InExecute = self:AddInput("Execute", "Execute", {
LINKID_DataType = "Number",
INPID_InputControl = "ButtonControl",
INP_Default = 1.0,
{ MBTNC_AddButton = "Execute", MBTNCD_ButtonWidth = 1/3, },
INP_Integer = true,
})
InLowV = self:AddInput("Low Value", "LowValue", {
LINKID_DataType = "Number",
INPID_InputControl = "RangeControl",
INP_Default = 0.0,
IC_ControlGroup = 2,
IC_ControlID = 0,
})
InHighV = self:AddInput("High Value", "HighValue", {
LINKID_DataType = "Number",
INPID_InputControl = "RangeControl",
INP_Default = 1.0,
IC_ControlGroup = 2,
IC_ControlID = 1,
})
OutImage = self:AddOutput("Output", "Output", {
LINKID_DataType = "Image",
LINK_Main = 1,
})
end
function Process(req)
--channel picker
local tChan = InImage.R
-- 0 = red
-- 1 = green
-- 2 = blue
-- 3 = alpha
-- 4 = luma
if channel == 0 then
tChan = InImage.Red
elseif channel == 1 then
tChan = InImage.Green
elseif channel == 2 then
tChan = InImage.Blue
elseif channel == 3 then
tChan = InImage.Alpha
elseif channel == 4 then
tChan = InImage.L
end
local F1 = InImage:GetValue(req).GlobalIn
local F2 = InImage:GetValue(req).GlobalOut
local TIME = (time/(F2-F1))
local HighF = tChan.High
local HighV = 0
local x = 0
local LowF = tChan.Low
local LowV = 0
local y = 0
local i = 0
if execute == 0 then
for i = F1, F2, 1 do
--setting value at first frame as default high value, and storing other values in x
if TIME == 0 then
HighF = HighV
else
HighF = x
--comparing x to the high value thus far
if x > HighV then
x = HighV
else
HighV = HighV
end
end
--setting value at first frame as default low value, and storing other values in y
if TIME == 0 then
LowF = LowV
else
LowF = y
--comparing y to the low value thus far
if y > LowV then
y = LowV
else
LowV = LowV
end
end
end
end
local img = InImage:GetValue(req)
img:Use()
OutImage:Set(req, img)
Like i said in my earlier post, I have no real experience in lua, so im looking things up, copying so reference, and in some cases making things up as i go along haha