Skip to content

Draw Mask

Interactive node to create a grayscale mask using a canvas. Produces a single-channel mask normalized between 0 and 1, where white is fully masked and black is unmasked. If the canvas is empty, it outputs a zero mask with the specified width and height.
Preview

Usage

Use this node when you need a custom, hand-drawn mask for tasks like inpainting, compositing, or selectively applying effects. Configure the canvas size before drawing to match your target resolution, draw on the canvas with the chosen brush size and color, and pass the resulting mask to downstream nodes that accept a MASK input.

Inputs

FieldRequiredTypeDescriptionExample
canvasTrueCANVASInteractive drawing surface input from the UI. Contains the strokes you draw to define the mask.Interactive canvas data from the UI
widthTrueINTOutput mask width in pixels. Also updates the canvas aspect ratio in the UI.512
heightTrueINTOutput mask height in pixels. Also updates the canvas aspect ratio in the UI.512
brush_sizeTrueINTBrush size used when drawing on the canvas in the UI.10
brush_colorTrueINTBrush color in grayscale for drawing on the canvas. 0 is black (unmasked), 255 is white (masked).255

Outputs

FieldTypeDescriptionExample
maskMASKSingle-channel mask tensor of shape 1×H×W with values in [0, 1]. White areas (1.0) indicate masked regions; black areas (0.0) indicate unmasked regions.A 1×512×512 mask tensor with values between 0 and 1

Important Notes

  • Canvas size matters: Set width and height to your intended final resolution before drawing to avoid resampling artifacts.
  • Empty canvas behavior: If nothing is drawn, the node outputs a zero mask with the specified width and height.
  • Value range: The mask is normalized to [0, 1], where 1.0 represents white (masked) and 0.0 represents black (unmasked).
  • Brush controls: Brush size and brush color control the drawing behavior in the UI; they are not separate inputs to downstream nodes.
  • Resizing: If the drawn canvas differs from the specified width/height, it is resized to match the target dimensions.

Troubleshooting

  • Mask appears blank: Ensure you are drawing with a nonzero brush color (e.g., 255 for white) and an adequate brush size.
  • Wrong mask size downstream: Adjust this node's width and height to match the expected resolution of downstream nodes.
  • Mask looks soft or blurry: Set the desired width and height first, then draw at that resolution to avoid resizing.
  • Mask is inverted: Use white for areas you want masked and black for areas you want unmasked. If needed, invert in a downstream node.
  • Nothing changes after drawing: Verify that the canvas input is being updated in the UI and that the node has been re-executed.

Example Pipelines

Example
Example