Separate a foreground object from a background using Roto Brush and create mattes using Refine Matte.

Separating a foreground object from a background is a crucial step in many visual effects and compositing workflows. When you’ve created a matte that isolates an object, you can replace the background, selectively apply effects to the foreground, and much more.

Use Roto Brush to draw strokes on representative areas of the foreground and background elements. After Effects uses that information to create a segmentation boundary between the foreground and background elements.

After creating the segmentation boundary, use Refine Matte properties to improve the matte.

 The Refine Matte effect is also available separately for the improvement of mattes created using features other than the Roto Brush tool.

Roto Brush 2

Powered by Adobe Sensei

Traditional rotoscoping uses animated masks to isolate an element in a video clip, which can be tedious and time-consuming. Roto Brush 2 uses artificial intelligence to track your subject’s movement so you can cut down on frame by frame refinement.

The default rotoscoping option is Roto Brush 2. If you prefer the older tool, you can select it by using xxx option in yyyy dialog.

Differences between Roto Brush 1 and Roto Brush 2

Roto Brush 1 Roto Brush 2
The propogation banner displays in the Layer panel.
The propogation banner displays in both the Layer panel and the Composition panel which contains the layer to which Roto Brush is applied. In case you have the Layer panel closed, you still see the propogation progress.

The Roto Brush and Refine Edge Span is thinner, with a plain gray section and a black section for the base frames.

When you propogate the frames, a thin green line displays in the middle of the span.

 

The Roto Brush and Refine Edge Span shows a light grey chevron pattern and the base frame is a bright green box at the beginning.

When you propogate the frames, green color chevrons display in the middle of the span. For more information, see Strokes, Spans, and Base frames.

The classic controls are enabled by default. The classic controls such as Motion Threshold and Motion Damping are not enabled by default. You can enable them by selecting Enable Classic Controls under the Roto Brush & Refine Edge effect.

If you prefer to stick to Roto Brush 1, then you ca

Workflow

If you are familiar with the Roto Brush 1, selecting objects with Roto Brush 2's propagation engine is largely the same:

  1. Select Roto Brush   in the toolbar ( Alt/Option + W ).

  2. Double click an existing layer in the Composition panel.

    This opens up the layer in the Layer panel.

  3. Select a frame to start from.

     Avoid frames where the object is hidden by other objects in the scene. For example - for a person walking in and out of frame, choose a frame where they are completely in the scene.

  4. Paint a green foreground stroke on the subject, object, or region you are attempting to roto.

    2020-06-11_14-54-41
    The object to be removed is outlined in magenta.

    Start with one stroke that cuts across the object. See what Roto Brush selects from that and use as few strokes as necessary to add or remove from the selection.

    Don't draw an outline around the object. Draw through the middle, passing through any regions on the object that have different color or brightness.

    Don't paint across edges as this can confuse the selection.

     

  5. Refine the selection.

    Paint extra strokes, or paint background strokes by holding Alt/Option to remove portions of the selection. Draw strokes around the edges that you want to remove.

    The magenta line that surrounds the object starts to get refined.

    In case you cut a little extra, release Alt/Option and drag over the area to add to the selection. The indication is that the cursor is green during addition. When you are drawing a background stroke, the Roto Brush tool’s pointer is a red circle with a minus sign in the middle.

    foreground_mirrorsmallerbrushsm
    Foreground stroke, adding to selection
    tehbhaexr0yc
    Background stroke, removing from selection
  6. Once the base frame is set, start the propagation.

    You can start propagation by:

    • Pressing the spacebar - This triggers the propagation of the matte from the base frame to the new frame. 
    • You can also propagate frame-by-frame either forward or backward, if you would like to go slower and evaluate the propagation more closely. This might be more ideal for footage which requires more correction strokes. You can also use these keyboard shortcuts to move frame by frame:
      • PgUp and PgDn 
      • Command + Left/Right arrows (macOS) or CTRL + Left/Right arrows (Win)
  7. As Roto Brush propagates the matte from frame to frame, the selection may start to include unwanted regions or "lose" portions of the original selection. To correct this, paint a background stroke (holding Alt/Option) on the first frame where the unwanted change occurs to remove unwanted regions, or paint a new foreground stroke to include anything that was missed. As with the base frame, avoid painting across the edge of the selection as much as possible.

    Note:

    You can resize the Roto Brush tool’s tip to make finer strokes. Broad strokes are best for initial work, but fine strokes are useful for details. (See Roto Brush strokes, spans, and base frames.)

  8. Freeze the propagation.

    After propagating the matte through all the video frames, freeze the propagation using the Freeze button at the bottom of the Layer panel.

    After freezing, you can continue to make adjustments to the matte without re-propagating. If you need to add or remove from a selection after freezing, you can unfreeze the propagation with the same button.

    Note that you should only freeze once you are satisfied with the Roto Brush matte. What Freezing does is that it locks the matte in place so that Roto Brush does not have to re-propagate the edges. To learn more see, Freezing (caching, locking, and saving) Roto Brush segmentation.

Adjusting and Refining the final matte

  • The result of the propagation can be further refined and improved via the controls in the "Roto Brush Matte" group in the Roto Brush effect, especially with the "Reduce Chatter" property. 
  • Additionally, the Refine Edge Tool can be used for highly-detailed edges like hair and further controlled in the "Refine Edge Matte" property group. There are also options that compensate for motion blur and decontaminating edge colors. It is useful when dealing with mattes with soft edges or fine details like hair.
  • Use the Refine Edge tool on other frames until the refinement is as precise and complete as possible. Press Alt/Option to erase Refine Edge strokes.
  • If you've used the Refine Edge brush, the Fine-tune Refine Edge Matte option in the Roto Brush & Refine Edge effect properties is selected. Modify properties in the Refine Edge Matte property group as needed. (See Roto Brush & Refine Edge, Refine Hard Matte, and Refine Soft Matte effect reference.)

Use the toggles at the bottom of the Layer panel to view the matte results, or open the Composition panel to view the result in-context with other layers. For more information, see Layer panel view options.

Getting started with Roto Brush 1

If you want more precise refining around the edges, you can use the Roto Brush 1, or combine it with the Roto Brush 2. The controls available to you in Roto Brush 1 by default can be activated in Roto Brush 2 by selecting the Enable Classic Controls option in the Preferences. The procedure to use it is largely the same as Roto Brush 2.

  1. Switch to the Roto Brush or Refine Edge tool by pressing Alt+W (Windows) or Option+W (Mac OS).

    Note: Once selected, you can press Alt+W (Windows) or Option+W (Mac OS) to toggle between these tools.

  2. Follow the same procedure from Step 2 to Step 8 of the Roto Brush 2.

Layer panel view options

AfterFX_(Beta)_2020-06-11_17-25-21
Toggles in Layer panel for viewing alpha, alpha boundary, and alpha overlay

You can choose these view modes from the Show Channel menu in the Layer panel, by clicking the buttons in the Layer panel, or by using keyboard shortcuts. You can use the controls at the bottom of the Layer panel to change the color and opacity of the overlays used in Alpha Boundary and Alpha Overlay mode.

Alpha

Shows alpha channel of layer (Alt+4 or Option+4).

Alpha Boundary

Shows source layer with foreground and background unchanged, with segmentation boundary overlaid as colored outline (Alt+5 or Option+5).

note: Alpha Boundary view mode is turned off when the View menu in the Layer panel is changed to anything other than Roto Brush.

Alpha Overlay

Shows source layer with foreground unchanged and background overlaid with a solid color (Alt+6 or Option+6).

Roto Brush & Refine Edge effect

This effect is applied automatically when the first Roto Brush or Refine Edge stroke is drawn in the layer panel. Use this effect to control the settings for the Roto Brush & Refine Edge tools. After you have created a segmentation boundary and the boundary edges that need refining, use the Roto Brush Matte and Refine Edge Matte properties to improve the matte.

When you first draw a Roto Brush stroke, the frame on which you are drawing becomes a base frame. The segmentation information (the information about what is defined as foreground and what is defined as background) defaults to the entire duration of the layer, or to the duration of any empty durations if multiple spans are present. The range of frames thus influenced by this base frame is its Roto Brush span. Little arrows in the span bar in the Layer panel show the direction in which the information is being propagated. If you draw a corrective stroke anywhere where the arrows point to the right, the information from that stroke is propagated forward; if you draw a corrective stroke anywhere where the arrows point to the left, information from that stroke is propagated backward. If you draw a stroke anywhere outside of a Roto Brush span, then you create a new base frame and span.

You can work your way forward a frame at a time from a base frame, making corrective strokes, and you don't have to worry about your strokes changing results on frames that you've already worked on. You can do the same thing going backward from a base frame.

The influence of each corrective stroke propagates forward or backward to affect all frames in that direction within the span, regardless of when the stroke is made. For example, if the base frame is at frame 10, you make a corrective stroke at frame 20, and then you make a corrective stroke at frame 15, then frame 20 will be affected by both of these corrective strokes—just as if you had made the corrective strokes in the other order.

Each time that you make a stroke within a span, the span grows, unless it can't because the span in which you're drawing is adjacent to another span.

  • To manually change a span duration, drag either end of a span.

  • To delete a span, right-click (Windows) or Control-click (Mac OS) a span and choose Remove Span.

  • To delete all spans, delete the instance of the Roto Brush effect.

In Roto Brush 2, there is a propagation banner at the bottom of the Layer panel which gives a status of the current propagating frame and the total number of frames. For example, "Roto Brush propagating frame 40 of 131".

Propagation banner
Propagation banner

The Roto Brush tool is similar in many ways to the paint tools, though it also has several important differences.

When the Roto Brush tool is selected, controls in the Paint panel are disabled. Roto Brush strokes have a duration of one frame, though their influence propagates forward or backward within a span.

You can change the brush size (Diameter) for the Roto Brush tool in the same way that you change it for the paint tools. You can use the Diameter control in the Brushes panel or Ctrl-drag (Windows) or Command-drag (Mac OS) in the Layer panel. Other controls in the Brushes panel do affect the Roto Brush tool, with the exception of Hardness.

You can copy Roto Brush Path properties, and paste them into masks, shapes, and instances of the Paint effect, just like you can with other kinds of paths. If you copy an individual stroke, the Roto Brush span information is not copied; however, if you copy the entire Roto Brush effect instance, it includes the Roto Brush span (and base frame) information.

You can use expressions on the Roto Brush effect's Path property in the same manner as the Paint effect's Path property.

When drawing a stroke with the Roto Brush tool, a new stroke is created even if another stroke is selected. This differs from the stroke replacement functionality for the paint tools.

Roto Brush strokes are in a Strokes property group within the Roto Brush property group in the Timeline panel.

Many keyboard shortcuts that work with paint strokes and paint tools also work with Roto Brush strokes and the Roto Brush tool. (See Paint tools (keyboard shortcuts).)

Roto Brush effect and Refine Matte effect preferences

The Roto Brush effect properties in the Propagation property group affect segmentation between foreground and background and how that segmentation information is used for contiguous frames in a span. Other properties of the Roto Brush effect affect the matte that is generated based on the initial segmentation. The Refine Matte effect includes all of the properties of the Roto Brush effect outside of the Propagation property group (except for Invert Foreground/Background).

  • Version: To select from the two Roto Brush versions - 1.0 (Classic) and 2.0.
Option to select and switch between different Roto Brush versions
Option to select and switch between different Roto Brush versions
  • Quality: Select the quality of detailing around the edgesStandard is faster and doesn’t have quite as much detail around the edges. Best is refined around edges.
Select and switch between the two Quality options
Select and switch between the two Quality options
  • PropagationProperties in the Propagation property group (except for View Search Region) affect all Roto Brush calculations. Any change to these properties requires a recalculation and propagation of the segmentation information from a base frame. Also, the results on a base frame itself are not affected by changes to these properties; therefore, it’s best to change these properties when the current-time indicator is a frame or two away from a base frame, so that you can see the result of the changes.
    • Search Radius: The radius of the area within which After Effects searches when looking for pixels that match from one frame to the next. You can change how the search radius adapts to regions with more or less motion using the Motion Threshold and Motion Damping properties. If the search radius is too small, some motion may be missed; if the search radius is too large, extraneous motion may be detected.
    •  View Search RadiusWhen selected, displays a green box around the subject. It indicates where the Roto Brush algorithm is searching for the subject. If the subject moves out of that frame, the  Roto Brush effect is lost. You can increase the percentage to a higher number to cover the entire area. It is slower but more accurate and covers more area.
    • Enable Classic Controls: In Roto Brush 2, Propagation also has this checkbox. This is only available when Version is set to 2.0 and passes the propagation result from the new algorithm through the Classic one for finer control of propagation and more edge details. It turns the old Roto Brush options such as Motion Threshold, Edge Detection, and Motion Damping back on. In the version 1.0, these options are on by default but in version 2, you need to enable them manually. If you're not getting the desired line segmentation results with Standard or Best, try enabling classic controls. Doing so creates a hybrid approach, using the best of Roto Brush 2 and Roto Brush 1).
      • Motion Threshold and Motion Damping: (Available in Roto Brush 1 by default, and when you enable classic controls in Roto Brush 2). These two properties control how the search region is constrained based on motion. Change Motion Threshold to set the motion level below which is considered no motion, where the search region will shrink to nothing. Motion Damping affects the remaining areas that are considered to be in motion. As you increase Motion Damping, the search region is tightened, with slow-moving areas tightening more than fast-moving areas. Constraining the search region in areas with little motion can reduce edge chatter in these regions. Constraining the search region too much will cause the automatic boundary detection to fall off the edge of the object.
      • Edge Detection: Choose whether to favor the segmentation boundary calculated for the current frame in isolation or the segmentation calculated based on the previous frame when determining the edge between foreground and background. The Balanced option considers the current frame and surrounding frames equally. Foreground objects with colors that match the background will usually benefit from Favor Predicted Edges.
      • Use Alternate Color Estimation: Subtly changes the process by which the Roto Brush effect determines what is foreground and what is background. Sometimes checking it helps with segmentation; sometimes it doesn't.
Enable Classic controls
Enable Classic controls
  • Invert Foreground/Background: Inverts which strokes are considered foreground strokes and which strokes are considered background strokes in the segmentation phase of the Roto Brush effect.
  • Fine-tune Roto Brush Matte: Use this to refine edges, reduce chatter, shift edges, work on contrast, and feather the selection.
  • Refine Edge Matte: 
    • Smooth: Increasing this value reduces the sharpness of the curves in the segmentation boundary by smoothing along the edge. Leave this number low when isolating a object with sharp features, such as hair.
    • Feather: Softness of the segmentation boundary. This property does nothing if Smooth is 0. In contrast to Smooth, Feather applies across the edge.
    • Choke: The amount of choking (contraction) of the matte relative to the value of the Smooth property. The result is very similar to that of the Choke property in the Matte Choker effect, but the value is given from -100% to 100% (instead of -127 to 127).
    • Reduce Chatter: Increase this property to reduce erratic changes to edges from one frame to the next. This property determines how much influence the current frame should have when performing a weighted average across adjacent frames to make the matte edges not move erratically from one frame to the next. If the Reduce Chatter value is high, the chatter reduction strong, and the current frame is considered less. If the Reduce Chatter value is low, the chatter reduction is weak, and the current frame is considered more. If the Reduce Chatter value is 0, only the current frame is considered for matte refinement. Tip: If the foreground object isn’t moving, but the matte edges are moving and changing, increase the value of the Reduce Chatter property. If the foreground object is moving, but the matte edge isn’t moving, decrease the value of the Reduce Chatter property.
  • Use Motion Blur: Check this option to render the matte with motion blur. The high quality option is slower, but generates a cleaner edge. You can also control the number of samples and the shutter angle, which have the same meaning as they do in the context of motion blur in the composition settings. (See Motion blur.)
  • Decontaminate Edge Colors: Check this option to decontaminate (clean) the color of edge pixels. The background color is removed from foreground pixels, which helps to fix halos and the contamination of motion-blurred foreground objects with background color. The strength of this cleaning is determined by Decontamination Amount (In Roto Brush 2, this is named as Amount).
    • Extend Where Smoothed: Only functional when Reduce Chatter is greater than 0 and Decontaminate Edge Colors is selected. Edges that are moved in order to reduce chatter are cleaned.
    • Increase Decontamination Radius (In Roto Brush 2, it is named as Increase Radius): Amount (in pixels) by which to increase the radius value for the cleaning of edge colors, in addition to any cleaning that covers feather, motion blur, and extended decontamination.
    • View Decontamination Map (In Roto Brush 2, it is named as View Map): Shows which pixels will be cleaned by decontamination of edge colors (white pixels in the map).

Freezing (caching, locking, and saving) Roto Brush segmentation

When the View menu in the Layer panel is set to Roto Brush, a Freeze button appears in the lower-right corner of the Layer panel. Click this button to cache and lock segmentation for all Roto Brush spans for the layer within the composition work area. This preserves the matte and saves it with the project, preventing the Roto Brush effect from recalculating the segmentation when you open the project again or make changes.

Freeze button
Freeze button

If After Effects has already calculated Roto Brush segmentation information for a frame when you click the Freeze button, then this information is cached. If the segmentation has not been calculated for a frame within a Roto Brush span, then After Effects must calculate the segmentation before freezing.

Frames with frozen (cached and locked) segmentation information are represented by blue bars in the Roto Brush 1 span view in the Layer panel (and purple bars in the Roto Brush 2 span view).

Purple bars in Roto Brush 2
Purple bars in Roto Brush 2 span view

Note:

If you click Stop in the Freezing Roto Brush dialog box, After Effects stops adding frames to the cache, but Roto Brush segmentation is still locked with the segmentation information cached up until the point that you clicked Stop.

To unfreeze Roto Brush segmentation, click the Freeze button again.

When Roto Brush segmentation is frozen, you can place the pointer over the Freeze button to see a tooltip that tells you when the cached information was created.

When Roto Brush segmentation is frozen, the pointer for the Roto Brush tool has a slash through it.

The information that is cached and locked is the result of Roto Brush strokes and the properties in the Propagation property group of the Roto Brush effect. Making changes to any of these items (for example, by drawing new Roto Brush strokes or modifying properties in the Propagation property group) has no influence on the result of the Roto Brush effect until you unfreeze segmentation. The properties in the Matte property group are not frozen.

Frozen Roto Brush segmentation information is cached and locked while the application is running, and the cached information is saved with the project.

Tips to work with Roto Brush

  • When drawing strokes to define a foreground object with the Roto Brush tool, begin by drawing strokes along the center of the object’s features. For example, draw a stroke along the skeleton rather than along the outline of an arm. Unlike conventional rotoscoping, which requires precise manual definition of boundaries, using the Roto Brush tool works by defining representative regions. After Effects can then extrapolate from those regions to determine where the boundaries are. Before you draw a stroke along a boundary to attempt to get a precise segmentation, be sure that you've drawn foreground strokes down the center of the object and made at least some rough background strokes on the other side of the boundary.

  • If you draw a Roto Brush stroke over the wrong area of the image, undo that stroke. (See Undo changes.) However, if After Effects misinterprets your stroke and includes or excludes too much of the image, don’t undo; further teach Roto Brush by drawing additional strokes to include or exclude regions.

  • Work with resolution set to Full when using the Roto Brush tool. Fast Previews modes, such as Adaptive Resolution, don’t work well with the Roto Brush tool, because switching resolutions requires a full recalculation of the segmentation information. For this reason, Fast Previews modes are turned off when you draw a Roto Brush stroke. This setting is shared by the Composition and Layer panels. (See Resolution.)

  • Use the Roto Brush tool in a composition with a frame rate set to match the frame rate of the layer's source footage item. A warning banner appears at the bottom of the frame in the Composition panel if the frame rate of the composition doesn't match the frame rate of the layer's source footage item. (See Frame rate.)

  • When you've gotten everything as good as you can with the Roto Brush effect, you can touch up the matte further using other compositing features in After Effects—such as by painting on the alpha channel. (See Compositing and transparency overview and resources.)

Points to note

  • Choose your starting frame wisely. The more precise and stable the frame is, the better the propagation is.
  • The Roto brush selection can only be made in the Layer panel so make sure you have your footage open there.
  • Older projects that used Roto Brush should still open with Roto Brush 1. If you open a project created in versions before v17.5 that used the older Roto Brush & Refine Edge effect, the version is set to 1. So, old projects render the same even when opened in the new version.