Eyeon:Script/Reference/Applications/Fuse/Classes/ScriptOperator/DoMultiProcess

From VFXPedia

< Eyeon:Script | Reference | Applications | Fuse | Classes | ScriptOperator
Revision as of 06:58, 4 September 2007 by Peter (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents


Summary

The DoMultiProcess function is used to seperate an image processing task into seperate chunks for more efficient processing on multiprocessor workstations.

Usage

self:DoMultiProcess(function threadinitfunc, table globalenv, integer chunks, function processfunc )

threadinitfunc (function, required)
This argument can be used to provide a per thread initialization function. This is useful in cases where the tool may need to calculate/remember something for each thread. If no thread initialization is required, pass nil to this argument instead.
globalenv (table, required)
The DoMultiProcess processfunc function only has access to values passed to it in this table. See the example for details.
chunks (integer)
This argument tells Fusion how many times to run the function specified by the processfunc argument.
processfunc (function, required)
This argument should be a function which will be run repeatedly on each chunk. The function is passed a single argument, which indicates which chunk it is processing.

Example

The following example is a variation on the Gain.Fuse found on the Example Fuses page.

FuRegisterClass("Gain", CT_Tool, {
	REGS_Category = "Fuses",
	REGS_OpIconString = "fGn",
	REGS_OpDescription = "Gain Fuse",
	})
 
function Create()
	InGain = self:AddInput("Gain", "Gain", {
		LINKID_DataType = "Number",
		INPID_InputControl = "SliderControl",
		INP_Default = 2.0,
		})			
 
	InImage = self:AddInput("Input", "Input", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})
 
	OutImage = self:AddOutput("Output", "Output", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})				
end
 
function chunk_y(y)
 
	local p = Pixel()
	for x=0,In.Width-1 do
		In:GetPixel(x,y, p)
		p.R = p.R * Gain
		p.G = p.G * Gain
		p.B = p.B * Gain
		Out:SetPixel(x,y, p)
	end
 
end
 
function Process(req) 
	local img = InImage:GetValue(req)
	local gain = InGain:GetValue(req).Value
	
	local out = Image({IMG_Like = img})
	
	self:DoMultiProcess(nil, { In = img, Out = out, Gain = gain }, img.Height, chunk_y)
	
	OutImage:Set(req, out)
end


Tips for DoMultiProcess (edit)

EyeonTips:Script/Reference/Applications/Fuse/Classes/ScriptOperator/DoMultiProcess