Primatte keys are created incrementally by sampling single pixels, or a range of pixels, from a blue or greenscreen image. This controls the polyhedron in colorspace that determines what pixels are in or outside the matte. To use Primatte, click Auto-Compute to automatically sense the backing screen color, eliminate it, and even get rid of some of the foreground and background noise. Alternatively, you can set operation to how you want to use the color samples, or use the left and right arrow buttons to step through all the operations. Then, use Ctrl+click or Ctrl+Shift+drag to select a single color or a range of colors from the Viewer. Primatte then uses these to adjust the polyhedron. Nuke provides unlimited Undo during this process.
Primatte is a trademark of IMAGICA Corp. Primatte patent is held by IMAGICA Corp.
Connection Type |
Connection Name |
Function |
Input |
bg |
The background image to replace the blue/green screen in the foreground. |
fg |
The foreground, or subject, image to key. |
|
mask |
An optional image to use as a mask. By default, the Primatte effect is limited to the non-black areas of the mask. At first, the mask input appears as triangle on the right side of the node, but when you drag it, it turns into an arrow labeled mask. If you cannot see the mask input, ensure that the mask control is disabled or set to none. |
Control (UI) |
Knob (Scripting) |
Default Value |
Function |
Primatte Tab |
|||
foreground |
foreground |
rgb |
Channels from the fg input containing the image to key and composite. |
background |
background |
rgb |
Channels from the bg input to composite over, and to calculate the spill suppression. |
crop |
crop |
N/A |
The area of the input image you want to keep. Anything outside this box is cropped. You can adjust the following: • x - the distance (in pixels) between the left edge of the original image and the left side of the crop box. • y - the distance (in pixels) between the bottom edge of the original image and the bottom edge of the crop box. • r - the distance (in pixels) between the left edge of the original image and the right side of the crop box. • t - the distance (in pixels) between the bottom edge of the original image and the top edge of the crop box. • w - the width of the crop box. This is only available if you click the wh button. • h - the height of the crop box. This is only available if you click the wh button. You can also adjust the crop box in the Viewer by dragging its edges. |
mask |
N/A |
disabled |
Enables the associated mask channel to the right. Disabling this checkbox is the same as setting the channel to none. |
mask |
none |
The channel to use as a mask. By default, the Primatte effect is limited to the non-black areas of this channel. |
|
invert |
invert_mask |
disabled |
Inverts the use of the mask channel so that the Primatte effect is limited to the non-white areas of the mask. |
Initialize |
|||
algorithm |
algorithm |
Primatte |
Choose which algorithm Primatte uses to calculate your keying result: • Primatte - The Primatte algorithm delivers the best results and supports both the solid color and the complement color spill suppression methods. It is the algorithm that uses three multi-faceted polyhedrons (as described further down in the this chapter) to separate the 3D RGB colorspace. It is also the default algorithm mode and, because it is computationally intensive, it may take longer to render. • PrimatteRT - is the simplest algorithm and therefore, the fastest. It uses only a single planar surface to separate the 3D RGB colorspace (as described further down in this chapter) and, as a result, does not have the ability to separate out the foreground from the backing screen as carefully as the above Primatte algorithm. Other disadvantages of the Primatte RT algorithm is that it does not work well with less saturated backing screen colors and it does not support the complement color spill suppression method. • Primatte RT+ - this is in between the above two options. It uses a six planar surface color separation algorithm (as described further down in this document) and delivers results in between the other two in both quality and performance. Other disadvantages of the Primatte RT+ algorithm is that it does not work well with less saturated backing screen colors and it does not support the complement color spill suppression method. |
Reset |
Reset |
N/A |
Resets all of the Primatte properties to their initial values. |
Auto-Compute |
Auto-Compute |
N/A |
This can be used as the first step in the Primatte operation. Its purpose is to automatically detect the backing screen color, remove it, and do some clean-up on the foreground and background noise. If the clip was shot with an evenly lit, well-saturated backing screen, the Auto-Compute button leaves you with an image that may only need some spill removal to complete your keying operation. |
viewer |
viewer |
disabled |
Opens a Primatte Viewer that displays a graphical representation of the Primatte algorithms and allows you to see what is happening as the various Primatte tools are used. It is a passive feature that has no adjustment capabilities, but it may prove useful in evaluating an image as you operate on it. |
Degrain |
|||
type |
graintype |
none |
Select the type of degrain to use: • none - you get the color of the exact pixel sampled. • small - gets the average color of a small region of the area around the sampled pixel. Use this when the grain is very dense. • medium - gets the average color of a medium-sized region of the area around the sampled pixel. Use this when the grain is less dense. • large - gets the average color of a larger region of the area around the sampled pixel. Use this when the grain is very loose. |
tolerance |
graintolerance |
0.2 |
Increases the effect of the Clean BG Noise tool without changing the edge of the foreground object. This allows you to tell the Primatte algorithm what brightness of pixels you think represents grain. You should try not to use too high of a value; otherwise, it affects the overall matte. |
Actions |
|||
operation |
mode |
Smart Select BG Color |
What the colors you sample in the Viewer do: • Smart Select BG Color - gets the sampled backing screen color, analyzes the original foreground image, and determines the foreground areas using the Primatte foreground detection routine. Then, using the newly determined foreground areas, performs a Clean FG Noise operation internally and renders the composite image. • Clean BG Noise - removes noise from the background. Any pixels you sample in the Viewer are known to be 100% background. White noisy areas in the 100% background region become black. • Clean FG Noise - removes noise from the foreground. Any pixels you sample in the Viewer are known to be 100% foreground. The color of the sampled pixels is registered by Primatte to be the same color as in the original foreground image. This makes dark gray areas in the 100% foreground region white. |
operation (continued) |
• Matte Sponge - sets the sampled color in the image to be 100% foreground. However, if the sampled color is already keyed out and removed, it leaves the current suppressed color. It only affects the key or matte information. This tool is usually used to quickly remove stray transparent pixels that have appeared during the chroma keying procedure. • Make FG Trans. - suppresses spill in foreground transparency. When this mode is selected, the opaque foreground color region sampled in the Viewer becomes slightly translucent. This operation is useful for the subtle tuning of foreground objects that are otherwise completely covered with smoke or clouds. • Restore Detail - brings back detail to the foreground. The completely transparent background region sampled in the Viewer becomes translucent. This operation is useful for restoring lost hair details, thin wisps of smoke and so on. • Spill Sponge - removes spill from a composite image. When this mode is selected, the background color component in the pixels sampled in the Viewer is keyed out and removed for the color region selected. |
||
operation (continued) |
|
|
• Spill(-) - removes color spill from the sampled pixel color (and all colors like it) in the amount of one Primatte increment. If spill color remains, another click using this tool removes more of the color spill. • Spill(+) - returns color spill to the sampled pixel color (and all colors like it) in the amount of one Primatte increment. This tool is used to move the sampled color more in the direction of the color in the original foreground image. It can be used to nullify a Spill (-) step. • Matte(-) - reduces the opacity of the matte for the sampled pixel color (and all colors like it) in the amount of one Primatte increment. If the matte is still too opaque, another click using this operational mode tool makes the sampled color region even more translucent. This can be used to thin out smoke or make a shadow thinner to match shadows in the background imagery. • Matte(+) - increases the opacity of the matte for the sampled pixel color (and all colors like it) in the amount of one Primatte increment. If the matte is still too translucent or thin, another click using this operational mode tool makes the sampled color region even more opaque. This can be used to thicken smoke or make a shadow darker to match shadows in the background imagery. It can only make these adjustments to the density of the color region on the original foreground image. It can be used to nullify a Matte (-) step. |
operation (continued) |
|
|
• Detail(-) - reduces foreground detail for the sampled pixel color (and all colors like it) in the amount of one Primatte increment. If detail is still missing, another click using this operational mode tool makes detail more visible. This can be used to restore lost smoke or wisps of hair. • Detail(+) - increases foreground detail for the sampled pixel color (and all colors like it) in the amount of one Primatte increment. If there is still too much detail, another click using this operational mode tool makes more of it disappear. This can be used to remove smoke or wisps of hair from the composite. Sample where detail is visible and it disappears. This is for moving color regions into the 100% background region. It can be used to nullify a Detail (-) step. • Fine Tuning Sliders - provides finer control over the removal of spilled background color. The color of the sampled pixel is registered as a reference color for fine tuning. To perform the tuning operation, select a Fine Tuning slider and move it to achieve the desired effect. • 3D Sample - When viewer is enabled in the Primatte properties, the sampled colors are displayed as a spray of white pixels in the Primatte Viewer. This allows you to see where the selected backing screen colors reside within the 3D RGB colorspace. • Simple Select BG Color - gets the sampled backing screen color, projecting a line in the opposite direction on the hue wheel and generating artificial pixels that may represent the FG object. Then, using the artificially generated foreground pixels, it performs a Clean FG Noise operation internally and renders the composite image. |
|
currentColor |
black |
To sample colors from the Viewer, make sure this is pushed in (displaying an eyedropper), then Ctrl/Cmd+click in the Viewer to pick single pixels, or Ctrl/Cmd+Shift+drag to pick a rectangle of pixels. |
adjust lighting |
adjustLighting |
disabled |
When enabled, based on the currently selected BG color, Primatte generates a clean, evenly lit backing screen to use in the keying operation. This can improve the results if you have a very unevenly lit backing screen. |
hybrid render |
hybridRender |
disabled |
When enabled, Primatte internally creates two keys from the same image: • core - This matte has the transparency removed, but suffers from the bad edges on the foreground object. • edge - This matte has a clean edge on the foreground, but suffers from transparency within the foreground object. The core matte with the bad edges is then blurred and eroded before it is composited over the edge matte that has the transparency, resulting in a composite with the best of both options. This can help you deal with foregrounds that contain a color that is close to the backing screen color. |
Adjust Lighting |
|||
threshold |
lightingSPoly |
10 |
When adjust lighting is enabled, determines if a grid pixel should be treated as a pure background sample, a simulated background sample, or a foreground sample. Increasing the value brings more of the foreground into the adjusted lighting. |
grid size |
lightingGridSize |
12 |
When adjust lighting is enabled, sets the grid size used. Increasing this value increases the grid resolution used in the adjusted lighting calculation. |
Hybrid Matte |
|||
erode |
hybridErode |
5 |
When hybrid render is enabled, sets the amount of erosion performed on the core matte. To view the results, set output mode to hybrid core and view the alpha channel. |
blur radius |
hybridBlurRadius |
0.5 |
When hybrid render is enabled, sets the blur radius used when blurring the core matte. To view the results, set output mode to hybrid edge and view the alpha channel. |
Fine Tuning |
|||
L-poly (spill) |
spill |
0 |
Adjust boundary between spill-suppressed opaque foreground and no-change opaque foreground. The more to the right the slider moves, the more spill is removed. The more to the left the slider moves, the closer the color component of the selected region is to the color in the original foreground image. |
M-poly (trans) |
matte |
0 |
Adjust boundary between partially transparent foreground and fully opaque foreground. Moving this slider to the right makes the registered color region more transparent. Moving the slider to the left makes the matte more opaque. |
S-poly (detail) |
detail |
0 |
Adjust boundary between completely transparent background and partially translucent foreground. Moving this slider to the right makes the registered color region more visible. Moving the slider to the left makes the color region less visible. |
Spill Process |
|||
replace with |
spillProcess |
complement |
The color spill replacement method to use: • no suppression - no spill suppression is applied. • complement - replaces the spill color with the complement of the backing screen color. • solid color - replaces the spill color with a solid color of your choice. Use replace color below to choose the color. • defocused background - replaces the spill color with colors from a defocused version of the background image. Use defocus to adjust the amount of defocus applied to the background buffer image. |
replace color |
replaceColor |
0.18 |
When replace with is set to solid color, allows you to select a solid color to use to replace the spill. |
defocus |
defocus |
10 |
When replace with is set to defocused background, sets the amount to defocus the background for spill process. |
Output |
|||
output mode |
output_mode |
composite |
Determines what the output from the node should be: • composite - premultiplies the foreground with the background based on the matte created. This is your final result. • premultiplied - outputs the premultiplied result of the Primatte node, along with the calculated matte. This can be useful if you want to do your compositing using a Merge node (with operation set to over) rather than Primatte. This allows you to color correct, transform, and otherwise process your image before compositing it over the background. Note, however, that Primatte works within the sRGB colorspace, whereas Nuke works within a linear colorspace. This means you need to add a Colorspace node after both Primatte and your original background image to convert their colorspaces to sRGB, then do your color corrections or transforms, merge the images together, and, finally, use another Colorspace node to convert the result back to linear. • unpremultiplied - outputs the unpremultiplied result of the Primatte node, along with the calculated matte. This can be useful if you want to do your compositing using a Merge node (with operation set to matte) rather than Primatte. This allows you to color correct, transform, and otherwise process your image before compositing it over the background. Note, however, that Primatte works within the sRGB colorspace, whereas Nuke works within a linear colorspace. This means you need to add a Colorspace node after both Primatte and your original background image to convert their colorspaces to sRGB, then do your color corrections or transforms, merge the images together, and, finally, use another Colorspace node to convert the result back to linear. |
output mode (continued) |
• notpremultiplied - outputs the original foreground pixels (instead of the result of the Primatte node), along with the calculated matte. • adjust lighting FG - outputs the light-adjusted foreground that the adjust lighting mode creates (this has a more even shade of the backing color with the foreground object). If adjust lighting is disabled, this option simply displays the un-optimized, original foreground image. • adjust lighting BG - outputs the optimized artificial backing screen that the adjust lighting mode creates (a clean backing screen that has no foreground object). • hybrid core - outputs the internally generated core matte, used when hybrid render is enabled. • hybrid edge - outputs the internally generated edge matte, used when hybrid render is enabled. |
||
output |
output |
rgba |
The channels to write the output image to. |
Keying with Primatte (User Guide instructions)
Keying with Primatte (a written tutorial)
Nuke 7.0 - Primatte 5 from The Foundry on Vimeo.
Keying - Step Up to Nuke Tutorial 8 from The Foundry on Vimeo.
One important task of compositing is the removal of bluescreen or greenscreen. Nuke provides a wide variety of keyers for this task. I am going to go through several of these very briefly just so you have an introduction. I have brought in two pieces of footage to try this on. There is a greenscreen of the man that we used previously and there is also a still image of a house. It just has a bright sky and, even though there is no green or blue in this particular photo, you can still use keyer tools to attack the sky and remove it. You can reach the keyer tools through the Keyer menu.
I am going to start with the simplest one, which is called Keyer. Now, even though it doesn’t have a lot of options, it is great for certain circumstances like this. I am going to drop down the A pipe between the Merge and the Read node. The Keyer has several operations, one of which is luminance key, which is default. You can also target certain colors like green, or certain properties like saturation. We will leave it at luminance for now. There is also a graph here, which represents the operation values. For example, this graph represents luminance, as it runs from 0 towards 1, or the maximum. There are also four yellow bars here: A, B, C, and D. You can click-and-drag those interactively. Now B and C are overlapping at the start, but you can separate them. As soon as I move these, the alpha matte will start to be formed. Let’s go take a look at that. I am going to go into the Viewer and press the A key; there’s the alpha channel. What this signifies is any pixel with a luminance value between B and C becomes opaque. Any pixel value that had a luminance between C and D, or B and A, has a tapering value somewhere between opaque and transparent. So, in this situation, what I can do is move B and A towards the far-left, and then adjust C and D to make the sky mostly transparent. For example, what this means is any pixel with a luminance value over 0.9 becomes 100% transparent, or if a pixel has a luminance value between 0.8 and 0.9 has tapering transparency.
Let’s go back to rgb. Press the A key again, and there we go. Now, it doesn’t look like anything is happening right now. What you have to do with the Keyer is premultiply the alpha. So, I will select the Keyer node, right-mouse-button-click, Merge > Premult. Premult multiplies the alpha values by the rgb values. Once I add this, the sky is removed. Now I can test this further. I can hook something up to the B pipe of the Merge. For example, I can right-mouse-button-click, and go to Image > Constant. Constant will produce a solid color - I will hook that up to the B pipe. Then go to the color wheel for that node and pick a color, like light blue. The sky is gone and now the Constant appears in the sky area.
Let’s move on to some other keyers. I am going to go back to the greenscreen footage. Now, in fact, you can have more than one Viewer in any project. You can make a new Viewer at any time by going to the Viewer > Create New Viewer (Ctrl/Cmd+I). If you have more than one Viewer, you can switch between them by clicking the tabs. So now, we are going to work on this greenscreen. The first keyer we will try here is Keylight, so Keyer > Keylight. The Foundry writes Keylight and, in fact, it is available in other compositing packages like After Effects, the functionality is the same. It looks a little intimidating at the start because of all the inputs. What you have to do is plug the Source into the greenscreen, in this case, the A pipe into the output. Now there are many options you can adjust. I am going to adjust the basic ones you need to remove the greenscreen. The first thing to do is select the Screen Colour. You can click the swatch here, get the eyedropper, and go back to the Viewer. There are several ways to sample pixels with the eyedropper. You can Ctrl/Cmd+click or Ctrl/Cmd+drag your mouse. I will try the drag, so click+drag, let go - the screen color is sampled and you will see it right here in the swatch, and also beside the Screen Colour property. Let’s take a look at the alpha. Now, Keylight offers this View menu, which you can change from Final Result to Combined Matte. That’s what the alpha channel looks like, so right now there is some gray in the transparent area. What you can do is raise the Clip Black to erode that. What the Clip Black does is it looks for any pixel less than the slider and it makes it 100% transparent. There is also some gray in the white area. You can lower Clip White to make them more opaque, and now the matte looks pretty good. Once the matte looks good, you can return the View to Final Result. Now, to test that, I will disconnect the Constant over here, and plug it into the B pipe here. There we go, that’s pretty successful. Let’s try another keyer. I am going to disconnect Keylight, disconnect constant, and move that aside.
Now we will try Primatte. Primatte has been updated for Nuke 7, so now it’s even more powerful. In this case, I need to hook the fg or foreground to the greenscreen and then the output to the A pipe. Primatte has a very powerful button called Auto-Compute. If you click that, it will attempt to identify the screen color and remove it. In fact, it does a really good job right off the bat. Let’s see what the alpha looks like. I will press the A key again, and there it is. Again, there is some noise around the edges. Fortunately, Primatte offers a long list of operations you can use to clean up the matte. For example, I can switch this menu to Clean BG Noise. Now I will zoom in, and now, I can sample those pixels that are too gray. Another way to sample is to Ctrl/Cmd+Shift and draw a marquee box around the problem area that samples a whole bunch of pixels at once.
So now the edges are looking better, but there is still some gray on his jacket. We can then switch the menu to Clean FG Noise and then sample those pixels. Now that becomes more opaque. Let’s take a look at the rgb again. Press the A key - there it is. It looks pretty clean, however, there is a lot of green spill from the greenscreen in his clothing. In that case, I can go to Spill Sponge and sample those pixels to pull the green back out. There it goes. Now it’s not perfect yet, but you can see how quickly you can move the green. Let’s go ahead and plug in the Constant though and see what that looks like. Alright, let's move on to one more keyer. I will disconnect this one, move it aside.
Now we are going to try the IBKGizmo and IBKColor: two nodes that are designed to work together to tackle greenscreen or bluescreen. So Keyer > IBKColour and Keyer > IBKGizmo. Now, the connections here are a little bit more complicated. Basically, the 1 input for the IBKColor goes into the greenscreen, as does the fg for the IBKGizmo. Then the c, or color input pipe for the IBKGizmo, goes to the IBKColor node. Then the A pipe for the Merge goes to the output of the IBKGizmo. Let’s take a look at the options. The first thing to change is the screen type for the IBKColor node. It is set to blue by default, but you can change it to green. That looks a little funny here in the Viewer, but what I can do to see what the IBKColor node is doing is plug the Viewer into that node. Here, it’s targeting the color green; whatever color is not green it’s removing. Now the aggressiveness of the removal is controlled by the size slider. If I increase that, there is more averaging and there is fewer and fewer non-green colors. Let’s plug the Viewer back into the IBKGizmo. The color information is passed from the IBKColor node to the IBKGizmo node, which the IBKGizmo node turns into a matte. Now the first thing you need to do with the IBKGizmo is make sure the screen type is set to the same color, in this case, green. Let’s plug the Constant into the B pipe and put the Viewer back to the Merge node, and there we go - successful greenscreen removal.
Now, I know all of these keyers have numerous options, which we didn't talk about. This is just to give you a brief introduction and to show you there is a wide range of keyers to tackle pretty much any type of footage.
“Tears of Steel” footage courtesy (CC) Blender Foundation - mango.blender.org