Matte Refine

Refine an alpha matte through sequential erode, dilate, and blur.

What it does

Matte Refine cleans up an alpha matte or mask in three optional steps, applied in order: erode chokes the edge inward, dilate spreads it outward, blur softens it. Each step runs only when its radius is above zero.

The refinement can be driven from the input's alpha channel or from the luminance of its colour, which covers a mask stored as greyscale in RGB rather than in alpha.

When to use it

ParameterTypeDefault
content_inOneOf([FieldOf(Raster)])
erodeNumber0
dilateNumber0
blurNumber0
channelString"Alpha"
erode_fieldOneOf([FieldOf(Raster)])
dilate_fieldOneOf([FieldOf(Raster)])
spatial_strengthField
strengthNumber1

Gotchas

Erode and dilate use a square box neighbourhood, not a circular one. Small radii look close to round; pushed high, they visibly square off corners.

Erode then dilate at matched radii chokes and restores the matte, which removes small noise without shrinking the overall shape. The two passes do not cancel exactly on fine detail, because box erode and dilate are not symmetric with the original edge.

With all three radii at 0, Matte Refine is a pure passthrough and does not even convert a Luminance-mode input to greyscale. Raise at least one radius above 0 for the Channel setting to take effect.

Worked example

  1. Add Matte Refine and wire a keyed or masked image into Content.

  2. Raise Erode a few pixels to eat back noisy or ragged edge pixels.

  3. Raise Dilate by roughly the same amount to bring the matte back to size.

  4. Add a small amount of Blur to soften the remaining edge so it composites cleanly.

  5. If the mask is stored as greyscale colour rather than alpha, switch Channel to Luminance.

See also

Erode · Blur · Key · Rasters (images)