# Create mattes, key and mask effects

> Make and refine mattes in Nodespell with Keyer, Erode/Dilate, Roto, Apply Mask and Mask Mix, and limit any effect with its Mask input.

Source: https://docs.nodespell.com/edit/masks-and-keying/ · Last updated: 2026-11-10

A matte in Nodespell is a grayscale image or alpha channel that says where something applies: white is fully on, black is off, gray is partial. Nodespell builds mattes with **Keyer**, **Roto** and AI cutouts, refines them with **Erode/Dilate**, and uses them to cut out images, mix two images, or limit any effect through its **Mask** input.

## Alpha, straight and premultiplied

Every image node in Nodespell carries RGBA. The alpha channel is the image's own matte. Two conventions matter when you combine layers:

- **Straight (unpremultiplied)** alpha keeps full colour values in RGB, with alpha stored separately.
- **Premultiplied** alpha stores RGB already multiplied by alpha, which is what Over-style merges expect.

Merge and Composite premultiply each foreground for you, and Custom merge expressions see straight alpha, so most graphs need no manual step. When you do need to switch, use **Premultiply** (multiplies RGB by alpha) and **Unpremultiply** (divides RGB by alpha). To move a matte between images, **Channel Copy** writes any source channel, or its luminance, into the target's R, G, B or alpha, much like Nuke's Copy or Shuffle.

## Pull a key with Keyer

**Keyer** writes a new matte from the image itself.

1. Add **Keyer** after your plate and connect the image.
2. Choose a **Mode** (table below). For **Chroma Distance**, set **Screen Color** to the backing colour.
3. Set **Output** to **Matte View** to see the matte as black and white.
4. Raise **Clip Black** until the background is solid black, and lower **Clip White** until the subject is solid white. **Softness** widens the transition between them.
5. Turn on **Invert** if the matte is the wrong way round.
6. Set **Output** back to **Write Alpha** or **Premultiplied RGB**.

| **Mode**                                          | Matte is based on                                                      | Use for                                                |
| ------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------ |
| **Luminance** (default)                           | Brightness of each pixel                                               | Bright elements on dark (fire, sparks, sky)            |
| **Chroma Distance**                               | Distance from **Screen Color**                                         | Any solid-colour backing                               |
| **Green Screen**, **Blue Screen**, **Red Screen** | How much that channel exceeds the other two; the backing goes to black | Coloured screens                                       |
| **Saturation**                                    | Colour saturation                                                      | Separating colourful subjects from neutral backgrounds |

| Control           | Default         | What it does                                                                                                                      |
| ----------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **Clip Black**    | 0.08            | Matte values at or below this become 0                                                                                            |
| **Clip White**    | 0.35            | Matte values at or above this become 1                                                                                            |
| **Softness**      | 0.02            | Extends the ramp between the clip points (0–0.5)                                                                                  |
| **Combine Alpha** | **Replace**     | **Replace** discards the input alpha; **Intersect** multiplies the new matte with it; **Union** combines their coverage           |
| **Output**        | **Write Alpha** | **Write Alpha** keeps RGB and writes alpha; **Matte View** shows the matte; **Premultiplied RGB** multiplies RGB by the new alpha |
| **Mix**           | 1               | Blends between the original alpha and the new matte                                                                               |

Keyer does not suppress spill. Reduce green or blue fringing afterwards with [Hue Correct](https://docs.nodespell.com/edit/color-correction/) or a grade limited by the matte.

## Grow or shrink a matte with Erode/Dilate

**Erode/Dilate** shrinks or grows edges, like Nuke's Erode filter.

| Control       | Options                                      | Notes                              |
| ------------- | -------------------------------------------- | ---------------------------------- |
| **Operation** | **Dilate** (default), **Erode**              | Dilate grows, Erode shrinks        |
| **Channel**   | **Alpha** (default), **Luminance**, **RGBA** | Which values the operation follows |
| **Radius**    | 0–16, default 2                              | Measured in whole pixels           |
| **Mix**       | 0–1                                          | Blend with the original            |

Erode a key by one or two pixels to remove a dark fringe, or dilate a garbage matte so it safely covers the subject.

## Draw shapes with Roto

**Roto** draws Bezier and straight-line shapes as a matte. It is available inside compositors only.

- Select the Roto node and draw in the compositor viewer with the **Pen**, **Rectangle** or **Ellipse** tools. With the Pen, click to place points and drag while clicking to draw a curve; click the first point or press `Enter` to close the shape, or `Esc` to cancel.
- Drag a point to move it, double-click a point to switch it between **Smooth** and **Sharp**, and double-click an edge to add a point. Hold `Shift` while drawing a rectangle or ellipse for a square or circle.
- In the shapes panel, set each shape's **Combine** to **Add**, **Subtract** or **Intersect**, rename, lock, hide or reorder shapes, and set **Edge softness** **Inside** and **Outside**, for the whole shape or selected points.
- **Output** is **Alpha Matte** (default) or **RGBA**.
- To animate a shape in a video Compositor, move the playhead and select **Add key**. Editing a shape on any frame adds or updates a key there.

## Cut out or mix through a matte

Two nodes apply a matte directly. Both work in the Graph and inside compositors.

| Node           | Inputs                                 | What it does                                                                                                                                                                                                                                                                                   |
| -------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Apply Mask** | **Image**, **Mask**                    | White keeps the image, black makes it transparent, gray is partial. **Mask source** is **Brightness** (default) or **Alpha**. Existing transparency is kept unless **Replace transparency** is on. **Strength** fades the effect. Output size matches **Image**; the mask is stretched to fit. |
| **Mask Mix**   | **B (base)**, **A (masked)**, **Mask** | White shows A, black shows B, gray crossfades. **Mix** at 0 returns B. Colours are alpha-weighted to avoid fringes. Output size matches **B**.                                                                                                                                                 |

**Light Wrap** helps a keyed element sit in its plate: it bleeds light from the image on its background input into the foreground's edges, with **Size**, **Intensity**, **Background Blur** and a **Blend** of **Screen**, **Add**, **Over** or **Soft Light**.

## Limit any effect with its Mask input

Most image effect nodes, such as Color Correct, Blur, Grade and Denoise, have an optional **Mask** input and a compact **Mask** control group in Parameters.

| Control         | Default   | What it does                                                                                                |
| --------------- | --------- | ----------------------------------------------------------------------------------------------------------- |
| **Mask Source** | **Alpha** | Which channel of the mask image drives the effect: **Alpha**, **Luminance**, **Red**, **Green** or **Blue** |
| **Invert Mask** | Off       | Applies the effect outside the mask instead                                                                 |
| **Mask Mix**    | 1         | Blends between the unmasked and masked result                                                               |

Many of the same nodes have **Channels**, which chooses the RGBA channels the node writes. Unselected channels pass through unchanged, so you can, for example, blur only alpha.

## Get a matte automatically

For an automatic cutout of a still image, use the **Silhouette** model node, which removes the background and returns a transparent **Cutout** at the original size. Its **Edge adjustments** let you expand or contract the edge, feather it, and reduce colour fringe. Silhouette is a model node, so it runs as a task on Nodespell rather than in your browser; see [Remove background](https://docs.nodespell.com/creative-tools/remove-background/). The Cutout's alpha can feed any Mask input, Apply Mask or Mask Mix.

## Frequently asked questions

### Is there an Alpha Matte node?

No separate node is named Alpha Matte. Use **Apply Mask** to cut out an image with a matte, **Mask Mix** to choose between two images, or Roto's **Alpha Matte** output for a drawn matte.

### Why is my keyed edge dark or fringed?

The edge may be premultiplied twice or carrying background colour. Check that only one Premultiply happens before Merge, erode the matte by a pixel with Erode/Dilate, and reduce spill with a hue-limited correction.

### Can I key a video?

Yes. Keyer works inside a video Compositor on every frame. Outside a compositor, Graph image nodes process still images.

### Which channel should a mask image use?

Use **Alpha** for cutouts and Roto output, and **Luminance** for grayscale mattes such as depth maps or painted masks.

## Related

- [Compositing](https://docs.nodespell.com/edit/compositing/): Merge modes and premultiplication.
- [Color correction](https://docs.nodespell.com/edit/color-correction/): spill and hue-limited fixes.
- [Depth and defocus](https://docs.nodespell.com/edit/depth-and-defocus/): depth maps as mattes.
- [Filters and effects](https://docs.nodespell.com/edit/filters-and-effects/): which effects accept masks.
- [Remove background](https://docs.nodespell.com/creative-tools/remove-background/): automatic cutouts.
