Eyeon:Script/Reference/Applications/Fuse/Classes/Image/ProcessPixels

From VFXPedia

Jump to: navigation, search

Contents


Summary

The ProcessPixels function will process every pixel within a specified range of a source image using the function provided as its last argument. The results will be written to a second destination image.


Usage

out:ProcessPixels(integer x_start, integer y_start, integer x_end, integer y_end, image source_image..., function process)

x_start, y_start, x_end, y_end (integer, required)
These four values are used to specify the range of pixels in the source image which will be affected by the process function.
source_image (image, required )
An Image object which will provide the pixels used for the calculations. At least one image is required, but additional images can be specified as well. For an example of a ProcessPixels function that uses two source images see the example below.
process (function, required)
A function which will be executed for each pixel in the range specified by earlier arguments. The function will be passed four arguments in the form function(x, y, p1, p2...) where x and y are the co-ordinates of the pixel and the remaining arguments are Pixel objects from each of the source images.


Example

The following example is taken from the BoolTest.Fuse example found at Example_Fuses.

function Process(req) 
	local img1 = InImage1:GetValue(req)
	local img2 = InImage2:GetValue(req)
	local operation = InOperation:GetValue(req).Value+1
	
	local out = nil -- fail if we don't meet below conditions
	
	local func = op_funcs[operation]
	
	-- Must have a valid operation function, and images must be same dimensions
	if func and (img1.Width == img2.Width) and (img1.Height == img2.Height) then
	
		out = Image({IMG_Like = img1})
		
		out:ProcessPixels(0,0, img1.Width, img1.Height, img1, img2, func)
		
	end
	OutImage:Set(req, out)
end


Tips for ProcessPixels (edit)

EyeonTips:Script/Reference/Applications/Fuse/Classes/Image/ProcessPixels