Skip to content

Mask Refine

Node icon
Mask

Refines a mask with erode, dilate, feather, threshold, and morphological operations.

Mask Refine is the primary tool for cleaning up and adjusting masks. Erode shrinks the mask (positive values) or dilates it (negative values). Feather applies a Gaussian blur for soft edges. Threshold binarizes the mask.

The morphology section offers advanced operations: Open (removes small noise), Close (fills small holes), Gradient (extracts edges), Top Hat (bright detail), and Black Hat (dark detail).

Mask

ThresholdToggle
Default: false

Binarize mask before refinement; off=preserve gradients

ThresholdInteger
Default: 128 Range: 0–255

Binarization cutoff; pixels >= threshold become white

Erode / DilateNumber · px/%
Default: 0.0 Range: -50.0–50.0

Positive=erode (shrink), negative=dilate (expand)

FeatherNumber · px/%
Default: 1.5 Range: 0.0–50.0

Gaussian blur on edges; 0=hard (pixel art)

InvertToggle
Default: false

Invert mask

Morphology

OperationChoice
Default: None

None/Open (remove noise)/Close (fill holes)/Gradient/Top Hat/Black Hat

  • NoneNo morphological operation — only erode, feather, and threshold apply.
  • OpenErode then dilate — removes small noise and thin protrusions while preserving overall shape.
  • CloseDilate then erode — fills small holes and gaps while preserving overall shape.
  • GradientDifference between dilation and erosion — extracts the edge/outline of the mask.
  • Top HatDifference between input and opening — isolates bright details smaller than the kernel.
  • Black HatDifference between closing and input — isolates dark details smaller than the kernel.
Kernel ShapeChoice
Default: Ellipse

Structuring element

  • RectangleSquare structuring element — affects pixels in a rectangular area.
  • EllipseCircular structuring element — most natural-looking morphological operations.
  • CrossCross-shaped structuring element — only affects pixels along horizontal and vertical axes.
Kernel SizeInteger
Default: 3 Range: 1–100

Kernel radius; actual kernel is (2*size+1) wide

IterationsInteger
Default: 1 Range: 1–10

Repeat count; higher amplifies the effect

Notes

Threshold slider only visible when Threshold is enabled. Morphology params only visible when Operation is active.

  • A small erode (1–2px) removes fringe pixels at mask edges.
  • Negative erode values dilate (expand) the mask, which is useful for extending selections.
  • Use Open to clean up noisy masks without changing the overall shape.
  • Close fills small holes in masks and works well for patching gaps in selections.