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).

Pins

ImageImage
InputOptional
MaskMask
InputOptional
ImageImage
Output
MaskMask
Output

Mask

ThresholdToggle
Default: false

Binarize the mask before refinement

Threshold ValueInteger
Default: 128 Range: 0–255
When Threshold is on

Binarization cutoff (pixels >= become white)

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

Positive: erode (shrink). Negative: dilate (expand)

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

Gaussian blur radius on mask edges

InvertToggle
Default: false

Invert the mask

Morphology

OperationChoice
Default: None

Additional morphological op (Open/Close/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
When Operation != None

Structuring element shape

  • 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 Size (px)Integer
Default: 3 Range: 1–100
When Operation != None

Kernel radius in pixels

IterationsInteger
Default: 1 Range: 1–10
When Operation != None

How many times to repeat the operation

  • 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.
  • Use Feather to soften hard mask edges into a smooth falloff.