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 Basics of Pulling a Key in Primatte

The example images are located in doc/pix/primatte directory.

 

 

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.

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.

Set the output mode to view the composite:


Inner Mechanics of Primatte

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.

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.


 

Undo and Primatte. The Undo function and Primatte are not best friends. To remove an operator, use the delete op button in the Primatte parameters. To pick a different color, click the Color Picker 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.

To delete an operator:

Use a holdout matte to mask problem areas such as the dark portion under her arm. Knowing when to cut your losses and start doing a roto is a sign of maturity and true inner spiritual growth. This is covered in the Masking Primatte section, so take your shoes off and put your bunny slippers back on.

The background of the key, especially on the left side, needs work.

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 space—the shells are scaled toward or away from the Center point—and 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).



Managing Operators

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.

To modify previous operators:

Masking Primatte

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 Alternative Masking Technique. You can also connect the QuickPaint node between the woman node and Primatte nodes. Paint over the text using a color picked off of the blue screen.Primatte then automatically makes that area invisible.

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.



Identifying Image Inputs. To identify inputs on the top of a node, position the cursor over the input "knot" and read its name in the Help box at the bottom-right of the interface.

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.

Spill Suppression

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 trans—the 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.

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.

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.

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.

Alternatives

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:

Always supply the background image unless you are setting output to Alpha Only.

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:

Save yourself the trouble and set your output to Alpha Only:

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.