ComfyUI Node: Mask

Class Name

Mask

Category
Blender
Author
AIGODLIKE (Account age: 730days)
Extension
ComfyUI-CUP
Latest Updated
2024-06-21
Github Stars
0.04K

How to Install ComfyUI-CUP

Install this extension via the ComfyUI Manager by searching for ComfyUI-CUP
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-CUP 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
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Mask Description

Versatile image mask manipulation tool for precise AI art applications, offering creation, modification, and application functionalities.

Mask:

The Mask node is a versatile tool designed to manipulate and transform image masks, which are essential in various image processing and AI art applications. This node provides a range of functionalities that allow you to create, modify, and apply masks to images or latent spaces, enhancing your creative workflow. Whether you need to convert images to masks, adjust mask properties, or combine multiple masks, this node offers the flexibility and control needed to achieve precise results. By leveraging the Mask node, you can effectively isolate specific areas of an image, apply effects selectively, or prepare images for further processing, making it an invaluable asset for AI artists looking to refine their digital creations.

Mask Input Parameters:

mask

The mask parameter is a fundamental input that represents the mask you wish to manipulate. It serves as the base for various operations such as thresholding, cropping, or expanding. The mask is typically a binary or grayscale image where different pixel values indicate areas of interest. This parameter is crucial as it defines the initial state of the mask that will undergo transformations.

value

The value parameter is a floating-point number used in operations like thresholding, where it determines the cutoff point for mask creation. For instance, in a thresholding operation, pixels with values above this threshold are set to one, while others are set to zero. The value parameter ranges from 0.0 to 1.0, with a default of 0.5, allowing you to fine-tune the sensitivity of the mask creation process.

expand

The expand parameter is an integer that specifies how much to grow or shrink the mask. Positive values expand the mask, while negative values contract it. This parameter is useful for adjusting the size of the masked area, with a default of 0, meaning no change. The range is determined by the maximum resolution of the image, allowing for precise control over the mask's dimensions.

tapered_corners

The tapered_corners parameter is a boolean that determines whether the corners of the mask should be tapered during expansion or contraction. When set to true, the corners are smoothed, creating a more natural transition. This parameter is particularly useful for achieving softer edges in the mask, enhancing the visual quality of the final output.

x, y, width, height

These parameters define the rectangular area for cropping the mask. x and y specify the top-left corner of the crop area, while width and height determine its size. These parameters allow you to isolate specific regions of the mask, with default values set to 0 for x and y, and 512 for width and height, providing a starting point for customization.

left, top, right, bottom

These parameters are used in feathering operations to specify the amount of feathering on each side of the mask. Feathering creates a gradual transition between masked and unmasked areas, enhancing the blend between different regions. The values range from 0 to the maximum resolution, allowing for precise control over the feathering effect.

image

The image parameter is an input that represents the image from which a mask will be derived. It is essential for operations like converting an image to a mask based on specific channels or colors. This parameter provides the raw data needed to generate a mask, serving as the foundation for further processing.

channel

The channel parameter specifies which color channel (red, green, blue, or alpha) to use when converting an image to a mask. This selection allows you to focus on specific aspects of the image, such as transparency or color intensity, to create a mask that highlights the desired features.

color

The color parameter is an integer representing a specific color value used to create a mask from an image. It allows you to isolate areas of the image that match the specified color, turning them into a mask. This parameter is particularly useful for tasks that require color-based segmentation.

Mask Output Parameters:

mask

The mask output parameter represents the transformed or newly created mask resulting from the node's operations. It is a crucial output that can be used in subsequent processing steps, such as compositing or applying effects. The mask output provides a visual representation of the areas of interest, enabling you to apply further modifications or use it as a guide for other creative processes.

Mask Usage Tips:

  • Experiment with different value settings in thresholding operations to achieve the desired level of detail in your mask. A lower value can capture more subtle features, while a higher value may focus on more prominent areas.
  • Utilize the expand parameter to adjust the size of your mask dynamically. This can be particularly useful when you need to fine-tune the mask's coverage to match specific elements in your image.
  • When working with feathering, start with small values for left, top, right, and bottom to gradually introduce the effect. This approach allows you to achieve a natural blend without over-softening the edges.

Mask Common Errors and Solutions:

"Invalid mask dimensions"

  • Explanation: This error occurs when the input mask does not match the expected dimensions for the operation.
  • Solution: Ensure that the mask dimensions align with the requirements of the node. You may need to resize or reshape the mask to fit the expected input size.

"Threshold value out of range"

  • Explanation: The threshold value provided is outside the acceptable range of 0.0 to 1.0.
  • Solution: Adjust the threshold value to fall within the specified range. This ensures that the thresholding operation can be performed correctly.

"Color value not recognized"

  • Explanation: The color value provided for mask creation is not valid or not present in the image.
  • Solution: Verify that the color value is correctly specified and exists within the image. You may need to adjust the color value to match the image's color palette.

Mask Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-CUP
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 Playground, enabling artists to harness the latest AI tools to create incredible art.