Constraint

Function
Constraint is a multifunctional node that restricts the effect of nodes to limited areas, channels, tolerances, or fields. Toggle the type switch to select the constraint type. Certain parameters then become active; others no longer have any effect. This is similar to the KeyMix node in that you mix two images according to a third constraint. KeyMix expects an image to be the constraint. Constraint allows you to set other types of constraints.

The Constraint node also speeds calculation times considerably in many cases. The speed increase always occurs when using the ROI or field mode, and for many functions when using channel mode. Channel mode decreases calculation time when the output is a result of examining channels, such as layer operations. Calculation time is not decreased, however, when it must examine pixels, such as warps and many filters. The tolerance mode may in fact increase calculation times, as it must resolve both input images to calculate the difference between the images.

Parameters
Type
Defaults
Function
clipMode
int
1

Toggles between foreground and background resolution.

0 = foreground resolution.
1 = background resolution.

type
int
0

This selects the type of constraint you are going to use.

AOI - Area of Interest (1) - This draws a mixing box.
Threshold - (2) - only changes within a tolerance are passed on.
Channel - (4) Only specific channels are modified.
Field - (8) - Only a selected field is modified.

To assign multiple constraints when working without the interface, add the constraint mode values together. For example, 7 indicates Area of Interest, Threshold, and Channel are active.

left,right, bottom, top
float
0, width, 0, height These are active only if type is set to 1 (See type, above). They describe a cropping box for the effect.
rTol, gTol, bTol, aTol
float
0,0,0,0 Tolerance values to be used if type is set to 2 (See type, above).
tLevel
int
0

Active only when type is equal to 2. This sets the tolerance to "lo" or "hi".

0 = "lo". Changes are made only if the difference between image1 and image2 are less than the Tolerance values you set.

1 = "hi" Changes are made only if the difference between image1 and image2 is greater than the Tolerance values.

tReplace
int
0 Active when type is set to 2. Toggles if the entire pixel is replaced, or just the channel meeting the Tolerance criteria.
channels
string
rgba If type is set to 4 (See type, above), the operation only applies to these channels.
field
int
0

If type is set to 8 (See type, above), effect only applies to 1 field:

0 = even field.
1 = odd field.

invert
int
0 Will invert the selection, i.e. everything beyond a color tolerance will be included, rather than below, etc.


Synopsis

image Constraint( 
  image Foreground, 
  image Background,
  int clipMode,
  int type,
  int left,
  int right,
  int bottom,
  int top,
  float rTol,
  float gTol,
  float bTol,
  float aTol,
  int tLevel,
  int tReplace,
  const char * channels,
  int field
);


Script

image Constraint( 
  Foreground, 
  Background,
  clipMode,
  type,
  left,
  right,
  bottom,
  top,
  rTol,
  gTol,
  bTol,
  aTol,
  tLevel,
  tReplace,
  "channels",
  field
);


Command Line

shake -constraint image clipMode etc...


Examples

shake lisa.iff -blur 30 -const lisa.iff 0 1 150 350 200 400
shake lisa.iff -solariz -const lisa.iff 0 2 0 0 0 0 "Linear(0,0@1,1@20)" -t 1-20


See Also
KeyMix, Field, Interlace, SwapFields, SetDOD, Mix