ComfyUI > Nodes > ComfyUI 1hewNodes > Mask Separate

ComfyUI Node: Mask Separate

Class Name

1hew_MaskSeparate

Category
1hewNodes/mask
Author
1hew (Account age: 1113days)
Extension
ComfyUI 1hewNodes
Latest Updated
2026-04-17
Github Stars
0.03K

How to Install ComfyUI 1hewNodes

Install this extension via the ComfyUI Manager by searching for ComfyUI 1hewNodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 1hewNodes 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

Mask Separate Description

Processes and separates masks in tensors for precise image region identification and isolation.

Mask Separate:

The 1hew_MaskSeparate node is designed to process and separate masks within a given tensor, which is particularly useful in image processing tasks where distinct regions need to be identified and isolated. This node is capable of handling masks of varying dimensions and normalizes them to ensure consistency in processing. By applying thresholding and connectivity criteria, it effectively segments the mask into distinct regions based on specified parameters. This functionality is crucial for tasks that require precise mask separation, such as object detection or segmentation in AI art projects. The node's ability to handle different mask dimensions and apply customizable criteria makes it a versatile tool for artists looking to manipulate and analyze image masks with precision.

Mask Separate Input Parameters:

mask

The mask parameter is a tensor that represents the input mask to be processed. It can have varying dimensions, and the node will normalize it to ensure it is in a suitable format for processing. The mask is expected to be a PyTorch tensor, and if it is not, the node will return an empty output. This parameter is crucial as it serves as the primary data that the node will operate on to separate distinct regions.

threshold

The threshold parameter is a float value that determines the cutoff point for distinguishing between foreground and background in the mask. It ranges from 0.0 to 1.0, with a default value typically set to ensure effective separation. A higher threshold will result in fewer regions being identified, as only areas with values above the threshold will be considered part of a region.

min_area

The min_area parameter specifies the minimum size of a region to be considered valid. It is an integer value with a minimum of 1, ensuring that only regions with a significant area are retained. This parameter helps in filtering out noise and small, irrelevant regions that do not contribute meaningfully to the mask separation.

connectivity

The connectivity parameter defines the connectivity criterion for region labeling. It can be set to either 1 or 2, corresponding to 4-connectivity and 8-connectivity, respectively. This parameter affects how pixels are grouped into regions, with higher connectivity allowing for more complex region shapes.

sort_mode

The sort_mode parameter determines the order in which the identified regions are sorted. This can be useful for prioritizing certain regions over others based on specific criteria, although the exact options for sorting are not detailed in the context.

Mask Separate Output Parameters:

result

The result parameter is a tensor containing the separated mask regions. Each region is represented as a separate slice in the tensor, allowing for easy manipulation and analysis. This output is crucial for further processing steps that require distinct mask regions.

count

The count parameter is an integer that indicates the number of regions identified and separated from the input mask. This provides a quick overview of the mask's complexity and the effectiveness of the separation process.

Mask Separate Usage Tips:

  • Ensure that the input mask is a PyTorch tensor to avoid errors and ensure smooth processing.
  • Adjust the threshold parameter based on the contrast and detail level of the mask to achieve optimal separation results.
  • Use the min_area parameter to filter out noise and focus on significant regions, especially in masks with a lot of small, irrelevant details.
  • Experiment with the connectivity parameter to see how different settings affect the shape and number of regions identified.

Mask Separate Common Errors and Solutions:

"Input mask is not a tensor"

  • Explanation: This error occurs when the input mask is not a PyTorch tensor, which is required for processing.
  • Solution: Ensure that the input mask is converted to a PyTorch tensor before passing it to the node.

"No regions identified"

  • Explanation: This message indicates that no regions were found in the mask that met the threshold and minimum area criteria.
  • Solution: Adjust the threshold and min_area parameters to ensure that regions are correctly identified. Lowering the threshold or reducing the minimum area requirement can help in identifying more regions.

Mask Separate Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI 1hewNodes
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.

Mask Separate