Constraint

Function
This multi-functional node restricts the effect of nodes to limited areas, channels, tolerances, or fields. You toggle the type switch to select what kind of constraint you are going to use. By doing so, certain parameters become active, others no longer have any effect. This works similarly to KeyMix in that you are mixing 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 will also speed up calculation times considerably in many cases. Speed up will always occur when using the ROI or field mode, and for many functions when using channel mode. Channel mode will decrease calculation time when the output is a result of examing channels, ie, Layer operations, but not when it has to examine pixels, ie, Warps and many filters. The tolerance mode may in fact increase calculation times, as it has to resolve both input images to calculate the difference between them.

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.

Because of the labeling, you can do multiple types of constraining in the script by adding the numbers together, i.e., 7 equals Area of Interest, Threshold and Channel are all 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