ComfyUI > Nodes > ComfyUI-UniversalToolkit > Separate Masks (UTK)

ComfyUI Node: Separate Masks (UTK)

Class Name

SeparateMasks_UTK

Category
UniversalToolkit/Mask
Author
whmc76 (Account age: 1110days)
Extension
ComfyUI-UniversalToolkit
Latest Updated
2026-03-16
Github Stars
0.07K

How to Install ComfyUI-UniversalToolkit

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

Separate Masks (UTK) Description

Efficiently divides a mask into distinct components using area, box, or convex polygon modes.

Separate Masks (UTK):

The SeparateMasks_UTK node is designed to efficiently divide a single mask into multiple distinct masks based on connected components within the mask. This functionality is particularly useful for isolating different objects or regions within a single mask, allowing for more detailed analysis and processing. The node identifies continuous regions, or connected components, in the input mask and creates separate masks for each component that meets specified size thresholds. This ensures that only significant components are retained, filtering out small noise or unwanted elements. The node offers three modes for component separation: area, which preserves the exact shape of each component; box, which creates rectangular bounding boxes around each component; and convex_polygons, which generates simplified convex polygon approximations. These modes provide flexibility in how components are represented, catering to different processing needs. By sorting components by their horizontal position, the node ensures a consistent and logical order of output masks. This node is invaluable for tasks such as separating multiple objects in a single mask, filtering components by size, creating individual masks for batch processing, and facilitating object isolation and analysis.

Separate Masks (UTK) Input Parameters:

mask

The mask parameter is the primary input for the SeparateMasks_UTK node, representing the initial mask that contains multiple connected components. This parameter is crucial as it serves as the basis for the separation process. The mask should be a binary or grayscale image where different regions or objects are represented by connected components. The quality and structure of this input mask directly impact the effectiveness of the separation process, as the node will analyze these components to create individual masks. There are no specific minimum or maximum values for this parameter, but the mask should be appropriately formatted to ensure accurate processing.

mode

The mode parameter determines the method used to separate the connected components within the mask. It offers three options: area, box, and convex_polygons. The area mode preserves the exact shape of each component, making it ideal for applications requiring precise component outlines. The box mode creates rectangular bounding boxes around each component, which can be useful for applications that require simplified representations. The convex_polygons mode generates convex polygon approximations, providing a balance between detail and simplicity. The choice of mode affects the output masks' shape and complexity, allowing users to tailor the separation process to their specific needs.

size_threshold

The size_threshold parameter sets the minimum size for components to be considered in the separation process. Components smaller than the specified width and height are ignored, effectively filtering out noise and insignificant elements. This parameter is essential for ensuring that only meaningful components are retained in the output, enhancing the quality and relevance of the separated masks. Users can adjust this threshold based on the scale and detail of the input mask, optimizing the node's performance for different applications.

Separate Masks (UTK) Output Parameters:

masks

The masks output parameter is a collection of individual masks, each representing a distinct connected component from the input mask that meets the size threshold criteria. These masks are sorted by their horizontal position, providing a logical order for further processing or analysis. Each mask in the output retains the characteristics defined by the selected mode, whether it be the exact shape, bounding box, or convex polygon approximation. This output is crucial for applications requiring isolated analysis or processing of individual components, enabling more detailed and targeted operations.

Separate Masks (UTK) Usage Tips:

  • To effectively use the SeparateMasks_UTK node, ensure that the input mask is well-prepared, with clear and distinct connected components. This will enhance the accuracy of the separation process.
  • Experiment with different mode settings to find the best representation for your specific application. For precise component outlines, use area; for simplified bounding representations, use box; and for a balance between detail and simplicity, use convex_polygons.
  • Adjust the size_threshold parameter to filter out noise and retain only significant components. This can greatly improve the quality of the output masks, especially in masks with varying component sizes.

Separate Masks (UTK) Common Errors and Solutions:

"Input mask is not properly formatted"

  • Explanation: This error occurs when the input mask does not meet the expected format, such as being non-binary or having incorrect dimensions.
  • Solution: Ensure that the input mask is a binary or grayscale image with distinct connected components. Verify the dimensions and format of the mask before inputting it into the node.

"No components meet the size threshold"

  • Explanation: This error indicates that none of the connected components in the input mask are large enough to meet the specified size threshold.
  • Solution: Lower the size_threshold parameter to include smaller components, or adjust the input mask to ensure that significant components are present and meet the threshold criteria.

Separate Masks (UTK) Related Nodes

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

Separate Masks (UTK)