Tutorial 3.4: Primatte |
This section describes the basic mechanics of the Photron Primatte keying plugin (as ported by the Shake team) and several suggestions for its use. However, it is recommended to also read About Keying and Spill Suppression to learn how to maximize the effectiveness of this node by combining it with other functions.
The example images are located in doc/pix/primatte directory.
Add an Image - FileIn node and read in woman.iff
and bg.jpg.
![]() |
![]() |
In the Node View, select the woman node.
Add a Key - Primatte node, and connect the bg node
to the second input (background) of the Primatte node.
In Primatte, you select a "center" value that is the average color of the key you want to pull. The concept of center is explained in the next section, Inner Mechanics of Primatte.
![]() |
![]() |
Nothing appears to change because only the alpha channel is initially modified. The output of the node is determined in the output parameters.
Position the cursor in the Viewer and press A.
The alpha channel shows a basic key is pulled. (If most of the background is medium grey, the Color Picker was inactive when the blue screen color was selectedensure the picker is active, and scrub the blue screen again.) The majority of the background should appear black in the alpha channel. To select a different blue screen color, ensure the Picker is active and scrub in the Viewer.
One of the first parameters in Primatte, output , determines what is passed out of the node. The output is set to alpha only by default.
In the output parameters, enable comp
.
So, what is this puppy doing all over your images? Whereas
Keylight is based on a model of light and its properties, Primatte
works by assigning color to 1 of 4 different zones through a series of color
scrubs. Each zone has its own qualities. These zones are constructed in
a 3D space created with the three RGB axes. The following illustration is
a 2D representation of this 3D space.
Based on this model, you expect most of the pure blue to fall inside zone 1 (Background); colors near blue in zone 3 (Transparent Fg); and the rest of the colors in zone 4 (Foreground). Zone 2 is not yet used, because you haven't assigned any color to the zone.
In the Primatte output parameters, enable status.
The black pixels are zone 1 (bg), the red pixels are zone 4 (fg), and the blue pixels are zone 3 (transparent fg).
Return the output to comp.
Do these zones affect your life in such a way that they inhibit or aid your ability to make frequent purchases of Cool Ranch Corn Chips? Absolutely not. It's just a bit of information so you can better understand the Inner Beautiful Primatte.
To assign color to different zones, pick one of the operator buttons and scrub color in the the foreground image. For example, her shirt is transparent in some places (that's not a line you see very often in technical documentation, is it?). Use the foreground operator to add more of the shirt to the foreground.
In the Viewer, press A to view the alpha channel.
In the Primatte operator parameters, click the foreground operator button.
The foreground operator is assigned and a new Color Picker is automatically activated.
![]() |
![]() |
|
To sample more foreground area, click the foreground button again and scrub.
When using Primatte, knowing when to stop is
important. The more scrubs you perform with the foreground and background
operators, the crunchier the matte edge becomes. This is bad. For example,
you cannot get the dark bit under her arm. Kind of like that nasty corner
in your shower, you can scrub on it but it doesn't disappear. This is a
clue that this particular color is buried way down in zone 1 (pure background).
If you try to assert this color as foreground, you are going to upset the
entire keying model. That is also bad.
If you tried to get the dark area under her arm with a foreground operator and failed miserably, you can delete the operator.
In the Primatte parameters, click the delete op button
below the currentOp parameter.
The background of the key, especially on the left side, needs work.
In the Primatte parameters, click the background operator
and scrub the left side of the image.
![]() |
![]() |
![]() |
In using the foreground and background operators,
as well as possibly the delete op button, you have assigned pixels
to either zone 1 or 4. Picking any of the 8 operators assigns color to a
different zone. The following is a chart of the operator/zone assignments.
Note that decolor all scales the entire 3D spacethe shells
are scaled toward or away from the Center pointand therefore does
not involve picking a color (only moving a slider). Also, to make fine
tuning effective, pick a color and then adjust the sliders. These
operators are explained in the next section. This illustration demonstrates
(roughly) how each operator dimples the surface of the shells through the
use of successive color picks. (You may have seen implementations of Primatte
in other software using a real 3D representation of the color space using
polygons. While cool, only about three people on the planet seem to understand
it).
One swell thing about Shake's implementation of Primatte
is that you can review, modify, or delete previous operators at any time.
You do not have to start over from scratch if you messed up. Use the parameters
shown in the following illustration to review, modify, or delete previous
operators.
The currentOp slider scrolls from 0 (the Center pick) to the number of applied operators. Each operation can be accessed by using the slider. The Center pick is always 0, and cannot be deleted.
In this section, use a holdout matte to clean up the key under her arm, and a garbage matte to eliminate the "image courtesy of Photron" text (which your client probably doesn't want, unless your client is Photron).
Garbage Matte: Use a garbage matte (or mask) to get rid of material that blocks the blue screen and you don't want to appear in the final image. For example, clean up the picture credit with a garbage mask. Garbage masks are typically made with the Image - RotoShape, Image - QuickPaint, or other keying nodes.
An unattached QuickPaint node is created.
Connect the QuickPaint node it to the third input (garbage matte)
of Primatte.
Show the composite (Primatte node) in the Viewer (click the left side of the node).
Ensure the QuickPaint parameter are loaded (click the right side of the node).
Click the soft-edged main brush (default)
to select the hard-edged brush
.
Note: With the cursor in the Viewer, press F3 to toggle brush types.
Paint across the text, and it disappears:
|
To select the channel for the garbage matte, use the gMatteChannel settings in the Primatte parameters.
Holdout Mattes: Use a holdout matte to promote an area that should be visible, but are keyed out because the color is close to the blue screen or green screen Center color. For example, use a holdout matte to eliminate the line under her arm, that the foreground operators did not clean up earlier.
|
To select the masking channel of the holdout matte, use the hMatteChannel settings in the Primatte parameters.
A final parameter that helps with multiple masks is the arithmetic parameter. The arithmetic parameter indicates how the Primatte key interacts with the alpha channel of the foreground. By default, it replaces it, but you can also add, subtract, or multiply the two masks. With this technique, you can pull several masks and combine the masks within Primatte. Since there is no incoming mask in this example, the arithmetic parameter has no effect.
Primatte has tools to assist with spill suppression. Spill suppression is the removal of reflected light (blue or green spill) on the foreground material that comes from the blue screen itself. In this example, blue spill is immediately evident on her white shirt. Although the suppression tools in Primatte are interesting and useful, as a general principle, you are encouraged to perform the suppression outside of Primatte with nodes such as HueCurves, SpillSuppress, and ColorReplace. As one client put it, "Why would you want to tackle two difficult tasks at once?". For information on this process, jump to About Keying and Spill Suppression. With that chilling little preamble, continue.
In this example, there are three primary areas that the blue spill is apparent: The edge of her hair, the shadows on her shirt, and possibly the little transparent bit of her skirt at her knees. The more foreground operators you apply, the more areas you must spill suppress. On the flip side, the fewer foreground operators you use, the more rotoscoping or paint touch up you must do. Isn't keying fun? A third option is to pull two keys with two separate nodes, and feed one key into the other. This option is also described in About Keying and Spill Suppression.
Tackle the hair first.
![]() |
![]() |
Now the shirt. You can use additional spill sponge operators, but instead use the fine tuning operator. The fine tuning operator is the same as using spill sponge, restore detail, and make fg transthe last two either bring back fine details such as individual hair strands, or push foreground material into the slightly transparent zone. The fine tuning operator is much easier to use than the spill sponge, restore detail, and make fg trans operators, as it has sliders to tune how much of those particular effects you want.
In the Primatte parameters, adjust the spillSponge slider (under the Color Picker box). The more you slide, the greater the range of suppressed area.
![]() |
![]() |
The spill-suppressed image appears slightly transparent. This is because Primatte pulls in background color to replace the blue color. Here is the logic: If you stand in front of a blue screen and you have blue spill, then conceivably if you stand in front of a red wall, you have red spill. Therefore, Primatte sucks in the background image color to replace the removed blue screen color. This is sometimes sufficient, but often needs a little help. If the definition of the background is too sharp (for example, the black top of the chair appears through her shirt), you must modify the image Primatte pulls the replaced color from.
In the Primatte parameters, set the output to comp.
In the Node View, select the bg node.
Shift-click Filter - Blur.
In the Blur parameters, set the xPixels and yPixels to 200 (an arbitrary value in this case).
Connect the Blur node to the replaceImage input (knot 6,
the last input) of the Primatte node.
Since the black chair backing has lost its definition, the shirt
appears less transparent. The alpha channel remains solid.
Note: Another popular trick with the kids these
days is to place a Color - Monochrome node on the foreground
image and connect it as the replaceImage instead of a Blur node.
Other useful nodes are Key - SpillSuppress, Color - AdjustHSV,
Blur and Monochrome, all on the foreground image. Here is a
generic example.
As another alternative for the spill suppression color, toggle replaceMode to use color, it uses the Replace Color. This fills a solid color to replace the removed blue spill color.
Ensure the composite is loaded in the Viewer.
In the Primatte parameters, toggle replaceMode to use color.
Click the Replace Color picker box, and scrub the color of the wall. This can be helpful, but can also create a glowing edge around your image, which probably is not what you want.
Another trick is to isolate the blue screen color with the Color
- ColorReplace node and select a different (non-blue) color before
it is keyed. For example, pick the blue spill areas on her shirt and use the
ColorReplace node to replace it with a medium grey color.
The following example shows the blue on her shirt as the Source
Color that is then replaced with color from the background image. The
range parameters are all set to 0, with the falloff parameters
all set to .2. Toggle on the ColorReplace affectAlpha parameter
and view the alpha channel of the ColorReplace node to test the area
you are modifying. The blue screen should still be pure black.
![]() |
![]() |
After using ColorReplace, delete some of the fine tuning operations in the Primatte parameters.
Primatte has a great deal of flexibility, both within
the node, or by preceding it with other nodes. You have the most flexibility,
however, when you do not composite inside of the Primatte node. You
can to apply effects to the foreground element such as Transforms or Blurs,
as well as spill suppression. In the following process tree, the Primatte
output is set to alpha only, and preMultiply is activated
in the Over node. Because Primatte does not process the edge
with color suppression operators, the edge stays much cleaner.
If you are color correcting in Primatte and set your output to on Black, feed in the background to get a better edge. Let's put it this way:
Even though you can output Primatte with a premultiplied foreground with no background image, you should supply the background input if possible, as Primatte still calculates in some of this information. If you don't supply the background image, you have nasty black ringing around the edges. If this is impractical, toggle over the replaceMode to use Color and supply an appropriate Replace Color. |
This has a corollary:
No background image is needed; do your spill suppression with HueCurves or SpillSuppress. It also ensures your image is unpremultiplied, making it ready to color-correct. |
For more information, jump to About Keying and Spill Suppression.