Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > ComfyUI_SamplingUtils > Modify Mask (Expand/Contract with options)

ComfyUI Node: Modify Mask (Expand/Contract with options)

Class Name

ModifyMask

Category
utils/mask
Author
silveroxides (Account age: 2211days)
Extension
ComfyUI_SamplingUtils
Latest Updated
2026-06-03
Github Stars
0.02K

How to Install ComfyUI_SamplingUtils

Install this extension via the ComfyUI Manager by searching for ComfyUI_SamplingUtils
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI_SamplingUtils in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Modify Mask (Expand/Contract with options) Description

Flexible node for altering masks in image processing, enabling precise adjustments for various transformations and formats.

Modify Mask (Expand/Contract with options):

The ModifyMask node is designed to provide a flexible and powerful way to alter existing masks in your image processing workflow. This node allows you to apply various transformations to a mask, such as expanding or shrinking its boundaries, inverting its values, or even converting it to and from different formats like images or latent spaces. By using ModifyMask, you can fine-tune the areas of interest in your images, enabling more precise control over subsequent processing steps. This node is particularly beneficial for tasks that require dynamic adjustments to mask regions, such as inpainting, compositing, or selective filtering, ensuring that you can achieve the desired effects with ease and precision.

Modify Mask (Expand/Contract with options) Input Parameters:

mask

The mask parameter is the primary input for the ModifyMask node, representing the binary or grayscale mask that you wish to modify. This parameter is crucial as it defines the initial state of the mask before any transformations are applied. The mask is typically a 2D array where each pixel value indicates the degree of masking, with values closer to 1 representing fully masked areas and values closer to 0 representing unmasked areas. The input mask can be derived from various sources, such as thresholding an image or extracting a specific channel from an image.

expand

The expand parameter controls the amount by which the mask is expanded or shrunk. It accepts integer values, where positive values will expand the mask, and negative values will shrink it. The default value is 0, meaning no change to the mask size. The minimum and maximum values are determined by the system's maximum resolution settings. This parameter is useful for adjusting the mask's coverage area, allowing you to include or exclude more of the image as needed.

tapered_corners

The tapered_corners parameter is a boolean option that determines whether the corners of the mask should be tapered during expansion or shrinking. When set to True, the corners will be smoothed, resulting in a more natural and less blocky appearance. The default value is True, and this option is particularly useful when you want to maintain a smooth transition between masked and unmasked areas, especially in organic or irregular shapes.

Modify Mask (Expand/Contract with options) Output Parameters:

mask

The output mask parameter is the modified version of the input mask after the specified transformations have been applied. This output retains the same dimensions as the input mask but reflects the changes made by expanding, shrinking, or inverting the mask. The modified mask can then be used in subsequent processing steps, such as compositing or filtering, to achieve the desired visual effects. The output mask is crucial for ensuring that the intended areas of the image are accurately targeted for further manipulation.

Modify Mask (Expand/Contract with options) Usage Tips:

  • To achieve a smooth transition between masked and unmasked areas, enable the tapered_corners option, especially when working with organic shapes.
  • Use the expand parameter to fine-tune the mask's coverage area, allowing you to include or exclude specific regions of the image as needed.
  • Combine the ModifyMask node with other nodes like ThresholdMask or InvertMask to create complex masking effects and enhance your image processing workflow.

Modify Mask (Expand/Contract with options) Common Errors and Solutions:

Invalid mask input

  • Explanation: This error occurs when the input mask is not in the expected format or dimensions.
  • Solution: Ensure that the input mask is a valid 2D array with appropriate pixel values, typically between 0 and 1.

Expand value out of range

  • Explanation: The expand parameter value exceeds the allowed range based on the system's maximum resolution settings.
  • Solution: Adjust the expand value to be within the permissible range, ensuring it does not exceed the system's resolution limits.

Tapered corners not applied

  • Explanation: The tapered_corners option is not functioning as expected, possibly due to incorrect parameter settings.
  • Solution: Verify that the tapered_corners parameter is set to True and that the input mask is suitable for corner tapering.

Modify Mask (Expand/Contract with options) Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI_SamplingUtils
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Modify Mask (Expand/Contract with options)