Oink
AIMatteRefinematte AIMatteRefine

AIMatteRefine

Turns a rough matte (matte input, e.g.

raw .md

Turns a rough matte (matte input, e.g. AIRoto or a keyer) into a detailed alpha with hair and motion blur. ViTMatte builds a trimap from the rough matte (edge width); BiRefNet HR and RVM (people) work without one. Model Auto picks the best ViTMatte that fits the free GPU memory (never a research model). Temporal smoothing blends neighbour frames warped by optical flow. Runs in the AI worker. MatAnyone 2 (research pack, non-commercial use only: accept its licence in the panel first) is video matting: each chunk of Video Chunk frames starts from the rough matte of its first frame and follows it through time, for temporally stable hair and motion blur.

NodeAIMatteRefine
MenuAI › AIMatteRefine
Names in each format
.oink comp (JSON)"type": "OC_N_aimatterefine"
.nk scriptnone: written as an Oink node
Pythonnuke.createNode("OC_N_aimatterefine")
Assistant (MCP)create_node(type="AIMatteRefine")
Tab searchaimatterefine, or its initials aimr

AIMatteRefine properties

Inputs and outputs

PortNameType
input 0Imageimage
input 1matteimage
output 0Imageimage

Knobs

Panel tab Aimatterefine, in panel order.

KnobLabelTypeDefaultRange / values.nk knobDescription
modelmodelmenuAUTOAUTO (Auto (by free GPU memory)), VITMATTE_BASE (ViTMatte base), VITMATTE_SMALL (ViTMatte small), BIREFNET (BiRefNet HR), RVM (RVM (humans)), MATANYONE2 (MatAnyone 2 (research pack, non-commercial))
matte_channelmatte channelmenualphaalpha, red, green, blueChannel of the matte input holding the rough alpha
edge_widthedge widthfloat201 to 200Width of the band around the rough edge the model may change (px)
strengthstrengthfloat10 to 10 = rough matte, 1 = fully refined (inside the edge band)
keep_knownkeep knownbooltrueBiRefNet / RVM: keep the rough matte's solid inside and outside
temporaltemporal smoothingfloat00 to 1Blend with neighbouring frames' refined alpha (0 = off)
temporal_radiustemporal framesfloat21 to 4 (integer)Neighbours on each side
temporal_methodtemporal methodmenuflowflow (optical flow), blend
tile_sizetile sizefloat10240 to 4096 (integer)ViTMatte tile size in px (0 = whole frame at once)
video_chunkvideo chunk (MatAnyone 2)float242 to 200 (integer)MatAnyone 2: frames per chunk; each chunk starts from the rough matte of its first frame (project range aligned)
video_sizevideo size (MatAnyone 2)float1080256 to 4096 (integer)MatAnyone 2: shortest side it works at (bigger plates are resized inside; more = finer hair, more VRAM)
outputoutputmenualphaalpha, premult (premultiplied), unmix (unmixed fg), matte

Other knobs (Python, .nk and the assistant; not on the panel)

KnobLabelTypeDefaultRange / values.nk knobDescription
gl_colorViewer Controls Colorfloat ×30, 0, 00 to 1
postage_stamp_frameStatic Frameint1-2147483648 to 2147483647
lifetimeStartLifetime Startint0-2147483648 to 2147483647
lifetimeEndLifetime Endint100-2147483648 to 2147483647
useLifetimeUse Lifetimebooleanfalse
cachedCachedbooleanfalse
bookmarkBookmarkbooleanfalse
dope_sheetDope Sheetbooleanfalse
clone_groupClone Groupstring
link_sourceLink Sourcestring
link_overridesLink Overridesstring
split_viewsSplit Viewsstring

Examples

Open these from Help › Examples…, or from the ? menu in this node's Properties panel.

  • AIMatteRefine: hair-quality edges from a rough matte (examples/ai/aimatterefine_edges.oink): A rough matte (the CandleGlass alpha, eroded by a Blur) goes into the matte input; AIMatteRefine (ViTMatte) rebuilds the soft edge from the plate.

On this page