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

From VFXPedia

< Eyeon:Script | Reference | Applications | Fuse | Classes | Image
Revision as of 19:08, 28 November 2007 by Izyk (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents


Summary

The Merge method will merge a FG image over the Image calling the method. The foreground image can also be offset, scaled and rotated. This function supports all of the apply modes and operations supported by the Merge tool.


Usage

Image:Merge(image fg, table attributes)

fg (Image, required)
The Image to be used as the foreground of the merge.
attributes (table, required)
A table containing entries which describe thow the foreground will be merged over the background. All values are optional, and an empty table will perform a default Additive merge of the foreground over the background. Valid entries include
  • MO_EdgeMode
    • "Black"
    • "Wrap"
    • "Duplicate"
  • MO_ApplyMode
    • "Merge"
    • "Screen"
    • "Dissolve"
    • "Multiply"
    • "Overlay"
    • "SoftLight"
    • "HardLight"
    • "ColorDodge"
    • "ColorBurn"
    • "Darken"
    • "Lighten"
    • "Difference"
    • "Exclusion"
    • "Hue"
    • "Saturation"
    • "Color"
    • "Luminosity"
  • MO_ApplyOperator
    • "Over"
    • "In"
    • "HeldOut"
    • "Atop"
    • "XOr"
  • MO_DoZ
  • MO_UseOpenGL
  • MO_MustDoCopy
  • MO_BBoxOnly
  • MO_FgZOffset
  • MO_BgZOffset
  • MO_XOffset
  • MO_YOffset
  • MO_XAxis
  • MO_YAxis
  • MO_XSize
  • MO_YSize
  • MO_Angle
  • MO_FgAddSub
  • MO_BgAddSub
  • MO_BurnIn
  • MO_FgRedGain
  • MO_FgGreenGain
  • MO_FgBlueGain
  • MO_FgAlphaGain
  • MO_BgAlphaGain


Example

This simple example Fuse additively merges the FG over the BG and provides no further options.

FuRegisterClass("SimpleMerge", CT_Tool, {
	REGS_Category = "Fuses\\Samples",
	REGS_OpIconString = "SMrg",
	REGS_OpDescription = "Simple Merge",
	})
 
function Create()
	
	InBackground = self:AddInput("Background", "Background", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})
 
	InForeground = self:AddInput("Foreground", "Foreground", {
		LINKID_DataType = "Image",
		LINK_Main = 2,
		})
 
	OutImage = self:AddOutput("Output", "Output", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})				
end
 
 
function Process(req) 
	local bg = InBackground:GetValue(req)
	local fg = InForeground:GetValue(req)
	
	local out = bg:Copy()
	out:Merge(fg, {MO_ApplyMode = "Merge"})
	
	OutImage:Set(req, out)
end


Tips for Merge (edit)

  • Image:Merge() re-seeds the random number generator if you use a Photoshop-style blend mode (i.e. anything else than Merge, Screen and Multiply). You should call math.randomseed() afterwards with a hard-coded seed value or a number entered by the user if you rely on predictable (sic) random numbers. Another solution is to create all your random numbers before calling :Merge().
  • If you want to preserve your background image, you can use MergeOf() instead. It will return the merge result as a new image.
  • MO_YSize does not work. You can change the foreground image's YSize member variable instead before doing the merge (don't forget to reset afterwards in case it's not a copy you're discarding anyway)
- No, you cannot, even temporarily, modify the foreground image's members if you didn't create the image yourself, because some other tool might be using that image at the same time! Stuart 05:45, 10 May 2013 (EDT)