Studio Yotsuba
Back to Node List

Morphology

morphology

Expands, shrinks, cleans, or fills mask shapes by a chosen pixel radius.

Reviewed
Guide available

Input Ports

NameTypeDescription
Image
input
Image
Required
Mask or image whose shape will be expanded or shrunk.
Control Map
control
Image
Optional map that allows morphology changes only in selected pixels.

Output Ports

NameTypeDescription
Image
output
Image
Result after the mask shape was expanded, shrunk, cleaned, or filled.

Parameters

NameTypeDefaultRangeDescription / Options
Operation
operation
Enum
Dilate—

Choose whether to grow, shrink, remove small dots, or fill small holes.

  • DilateDilate
    Expand selected areas outward.
  • ErodeErode
    Shrink selected areas inward.
  • OpenOpen
    Remove small isolated dots while keeping larger shapes.
  • CloseClose
    Fill small holes inside shapes while keeping the outside size close.
Source
source
Enum
Alpha—

Choose the scalar channel processed by grayscale min/max morphology; values are not binarized.

  • OKLCH-LOKLCH-L
    Use perceived brightness. Good when you want the result to match how bright it looks.
  • OKLCH-COKLCH-C
    Use how colorful the pixel is.
  • HSV-SHSV-S
    Use HSV saturation.
  • HSV-VHSV-V
    Use HSV value.
  • RGB-RRGB-R
    Use the red channel.
  • RGB-GRGB-G
    Use the green channel.
  • RGB-BRGB-B
    Use the blue channel.
  • AlphaAlpha
    Use alpha.
  • LuminanceLuminance
    Use Rec.709 RGB luminance.
Radius
radius
Int
11–16

How many pixels the shape can grow, shrink, or clean.

Shape
shape
Enum
Square—

Shape used when looking around each pixel. Square affects corners more, Diamond keeps diagonal corners tighter.

  • SquareSquare
  • DiamondDiamond
Output Mode
output_mode
Enum
Mask—

Choose whether the result is a mask image or updated transparency on the original image.

  • MaskMask
    Output a grayscale mask.
  • AlphaAlpha
    Keep the original colors and only change transparency.
Output Region
output_region
Enum
Full—

Choose the complete result or only the changed pixels.

  • FullFull
    Output the complete processed shape.
  • AddedAdded
    Output only pixels added by the operation.
  • RemovedRemoved
    Output only pixels removed by the operation.
Preserve Original
preserve_original
Bool
false—

For Close, keep every originally selected pixel while filling holes.

Control Source
control_source
Enum
Auto—

Choose how the optional control map is interpreted.

  • AutoAuto
    Use alpha when the map contains transparency; otherwise use luminance.
  • OKLCH-LOKLCH-L
    Use perceived brightness. Good when you want the result to match how bright it looks.
  • OKLCH-COKLCH-C
    Use how colorful the pixel is.
  • HSV-SHSV-S
    Use HSV saturation.
  • HSV-VHSV-V
    Use HSV value.
  • RGB-RRGB-R
    Use the red channel.
  • RGB-GRGB-G
    Use the green channel.
  • RGB-BRGB-B
    Use the blue channel.
  • AlphaAlpha
    Use alpha.
  • LuminanceLuminance
    Use Rec.709 RGB luminance.
Control Threshold
control_threshold
Float
0.50–1 / step 0.01

Morphology changes are applied where the control map is at or above this value.

Invert Control
control_invert
Bool
false—

Invert the optional control map before thresholding.

Wrap X
wrap_x
Bool
false—

Treat left and right edges as connected while expanding or shrinking the mask.

Wrap Y
wrap_y
Bool
false—

Treat top and bottom edges as connected while expanding or shrinking the mask.

Overview

Expands or contracts white areas in a mask and cleans up small specks or holes. Use it to grow a selection slightly, remove thin noise, or adjust the edge of a transparent region.

The component selected by source is processed as continuous grayscale values with min/max morphology; it is not binarized. Gray or translucent mask values therefore remain meaningful in the result.

Usage tips

  • Remember the four operations this way: Dilate = expand, Erode = contract, Open = remove white specks (contract, then restore), and Close = fill holes (expand, then restore).
  • With wrapping off, Close does not treat pixels outside the canvas as holes, so it preserves source shapes that touch a canvas edge.
  • Preserve Original is shown and applied only for Close. If an older file retains it for another operation, that value is ignored and a warning is shown.
  • Combinations that are necessarily empty, such as Dilate + Removed, return an empty result and show a warning on Output Region.
  • A go-to mask preprocessing step is to clean an automatically generated mask (from edge_detect or a threshold node) once with Open / Close before using it.
  • Choose between this and pixel_cleanup by scope: Pixel Cleanup for conservative, 1px-only cleanup; Morphology for full shaping with a specified radius.

Related nodes

  • pixel_cleanup — lightweight, 1px-only cleanup
  • mask / mask_boolean — destinations for the cleaned mask
  • distance_field — another shaping approach based on distance from the boundary
  • outline — a dedicated outline instead of one produced by expansion

Examples

  • Use Dilate to expand a character mask by 1px as the basis for an outline.
  • Use Erode to contract a mask slightly and remove bleeding along the edge.
  • Use Open to remove small white noise dots.
  • Use Close to fill small holes in a filled area.
  • When processing a tile mask, enable wrap_x / wrap_y so edge shapes connect to the opposite side.
Back to Node List