Primatte

Function
This plug-in is the latest update of Photron's Primatte keying software. With it, you are able to scrub across an image to determine matte areas in order to pull a key (or alpha channel) for a composite. The plug-in will also work on the RGB channels to suppress spill (the leaking of blue or green color onto the foreground objects).

Note the script uses a special series of information that it passes to the Primatte plug-in. These numbers are encoded, which means that Primatte must be set using the interface.

It is recommended to also read the Primatte tutorial as well as About Keying and Spill Suppression to learn how to maximize the effectiveness of this node by combining it with other functions.

Suppplying the Background image

Even though you can output Primatte with a premultiplied foreground with no background image, you should still supply the background input if possible, as Primatte still calculates in some of this information. If you don't supply this image, you will have nasty black ringing around the edges. If this is impractical, toggle over the replaceMode to use Color and supply an appropriate Replace Color.



Primatte works by assigning color to one of four zones by clicking on one of the 8 large operator buttons and then scrubbing for a color on the Viewer. These four zones are arranged around a center point in 3D color space, with each zone like a layer of an onion. Here is a chart of the operator/zone assignments. Note that decolor all scales the entire 3D space, shifting all color either towards or away from the foreground, and therefore does not involve picking a color, only moving a slider.



Operator Function

Center

This is the initial pixel scrub, and is always operation 0. This determines the center of the 3D polyhedron (described above), and so is therefore extremely important. The multiplier slider modifies the size of the center area in 3D space. Therefore, a higher multiplier value will expand the size of the background space, sucking in more of that color. The result will be more transparent. A value lower than 1 will reduce the amount of color sucked out by the initial background color pick.
Background This assigns pixels to the background. They will be 100% transparent with no spill suppression.
Decolor All This will shrink or expand the polyhedron between zone 4 (all foreground) and zone 3 (foreground plus spillsuppress). By using a positive value on the slider, the shell expands, effectively shifting across the entire image more color from the foreground into the suppressed area. By using a negative value, the shell is contracted, thereby slipping more values away from the suppressed area into the foreground area. Because the shells cannot intersect, if you shrink it too much, you will also crush the smaller interior shells, causing all values to shift towards the background.
FineTuning

spillSponge: When this mode is selected, the cursor motion in the Decolor slider performs a color adjustment of the sampled color against the background. After sampling a color region from the image, the more to the right the cursor moves, the less of the background color component (or spill) will be included in that color region. The more to the left the cursor moves, the closer the color component of the selected region will be to the spill suppress color.

fgTrans: Adjusts the transparency of the matte against the sampled color. After sampling a color region from the image, the more to the right the cursor is, the more transparent the matte becomes in that color region. This is equivalent to Make FG Trans, but has more control.

detailTrans: Determines the transparency of the sampled color when it is close to the background color. The slider in this mode is useful for restoring the color of pixels that are faded because of a similarity to the background color. If you slide to the left, picked areas are more opaque. This is equivalent to Restore Detail, but has more control.

Foreground When this mode is selected, the sampled pixels within the image window become 100% foreground. The color of the sampled pixels will be the same color as in the original foreground image. The matte is completely white.
Make FG Trans This makes foreground material have more transparency. This is for adjusting elements like clouds or smoke. It is the equivalent of fgTrans in FineTuning, except it has no slider control
Matte Sponge This is used to restore foreground areas lost during spill suppression. It only affects the alpha channel.
Restore Detail This removes transparency on background material. It is useful for restoring lost details like hair. It is the equivalent of Fine Tuning - detailTrans, but doesn't have a slider.
Spill Sponge Affects the color of the foreground, but not the matte. It suppresses the color you pick. This is usually used on spill areas that are known to be opaque, ie, bluespill on the face or body. If the change is too drastic, supplement or replace the operation with Fine Tuning - spillSponge.



These are the other parameters in the Primatte plugin:

Parameters
Type
Function
foreground
image
The blue- or greenscreen image
background
image
The background image. For some reason, it seems to work better with this here if you are setting output to "on black" or "comp".
garbageMatte
image
This is used to get rid of rigging or other elements you want to be transparent that are otherwise not pulled by the keying operation.
holdoutMatte
image
This is a matte input for things you want to be opaque
defocusedFg
image
This can be used to take a blurred version of the bluescreen to help deal with grain variation for film plates. Typically, you would attach a Blur node to the bluescreen footage and insert it here.
replaceImage
image
You can do spill suppression either with a solid color, with the background image (when no replaceImage is supplied) or with an alternative replaceImage to give the color that will go into spill suppressed areas. Common inputs for this are: bg, bg with Blur applied to it, fg with Blur applied to it, fg with Monochrome applied to it, or fg with AdjustHSV attached to it.
clipMode
int
The resolution to take, either the foreground (0) or the background (1)
output
int

You are not obliged to use Primatte to do your composite. This is especially helpful if you want to do transformations on the foreground object after pulling the matte. We recommend pulling the matte on the full resolution image before any scaling is done. The output setting determines what is changed by Primatte:

0 Alpha Only - only the matte is affected.
1 On Black - The foreground image and the matte are changed.
2 Composite - If there is an optional second input image, this will composite that background in.
3 Status - This special output gives you a color code to determine where each of the pixels is positioned in the 4 Primatte zones.
Black - Zone 1 - All background
Blue - Zone 2 - Transparent Foreground
Green - Zone 3 - Suppressed Foreground
Red - Zone 4 - All foreground.

arithmetic
int

Determines how Primatte affects the foreground matte channel.

0 Replace - replaces the fg matte channel completely.
1 Subtract - Subtracts the Primatte-derived matte from the in-coming matte.
2 Multiply - Multiplies the two mattes together.
3 Add - Adds the two mattes together.

processBGColor
int
This toggle tells Shake whether to consider the pixels outside of the frame or not. When this is off (default mode), outside of the image is assumed to be 100% transparent. When this is on, outside of the frame gets treated the same way black pixels are treated by your Primatte scrubs.
g,hMatteChannel
string
The channels to be used for the garbage and holdout Mattes. If there is no input for those image plugs, these parameters have no affect.
replaceMode
int
When you perform spill suppression through the use of the spillsponge operator or the fine tuning operator, these suppressed areas are shifted from blue (or whatever your center value is) towards a different color. By default, you use an image, which is either the background image or the replaceImage if that input is used. You can toggle it over to use color (1) to alternatively use the Replace Color.
Replace Color
float
The color to be used in the spill suppressed area. This is active only if replaceMode is set to 1 - use color.
Current Operation
int
This slider picks the current scrub. Each scrub operation is maintained separately in memory. You can move the slider to return to any previous scrub and adjust or delete it. To see the type of operation you have done, look at the Scrub Color Button.
Delete
NA
This deletes the current operation (see above). It does not reset Primatte to zero, unless of course you delete all operations. A better way to re-set Primatte is to click on the Primatte node and hit Ctrl+click on the function in the Function Tabs.
Scrub Color
NA
This is the currently picked color. To re-pick it, press the button and scrub. You should scrub across the un-modified RGB values. The type of scrub you have done appears in the Scrub Button top.
Eval to End
NA
As you adjust the Current Operation slider, you may want to see the composite only up to that point. Turn off Eval to End to evaluate only up to your current operation.
Active
NA
You can disable any operation you have done. This is used in conjuction with the Current Operation slider.
Amount
NA
The amount of adjustment. This slider disappears if the current operation does not have a modifier.

 

Synopsis

image = PrimatteX( 
  image foreground, 
  image background, 
  image garbageMatte,
  image holdoutMatte,
  image defocusedForeground,
  image replaceImage,
  int IDontKnow,
  int clipMode,
  int output,
  int arithmetic,
  int processBGColor,
  const char * gMatteChannel,
  const char * hMatteChannel,
  int replaceMode,
  float rReplace,
  float gReplace,
  float bReplace,  
  const char * encryptedPrimatteSettings

);

Script

image = PrimatteX( 
  foreground,
  background, 
  garbageMatte,
  holdoutMatte,
  defocusedForeground,
  replaceImage,
  something,
  clipMode,
  output,
  arithmetic,
  processBGColor,

  "gMatteChannel",
  "hMatteChannel",
  replaceMode,
  rReplace,
  gReplace,
  bReplace, 
  "encryptedPrimatteSettings"

);

See Also
ChromaKey, SpillSuppress, LumaKey, DepthKey, DepthSlice, Keylight