ComfyUI  >  Nodes  >  Masquerade Nodes >  Combine Masks

ComfyUI Node: Combine Masks

Class Name

Combine Masks

Category
Masquerade Nodes
Author
BadCafeCode (Account age: 485 days)
Extension
Masquerade Nodes
Latest Updated
6/19/2024
Github Stars
0.3K

How to Install Masquerade Nodes

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

Combine Masks Description

Merge mask images with various operations for complex compositions, ideal for AI artists.

Combine Masks:

The Combine Masks node is designed to merge two mask images using various operations, allowing you to create complex mask compositions easily. This node is particularly useful for AI artists who need to manipulate and combine different mask layers to achieve specific effects in their artwork. By providing multiple operations such as union, intersection, difference, and more, the Combine Masks node offers a versatile toolset for mask manipulation. This node simplifies the process of combining masks, ensuring that you can achieve the desired results without needing extensive technical knowledge.

Combine Masks Input Parameters:

image1

This parameter represents the first mask image to be combined. It serves as one of the two primary inputs for the combination operation. The quality and content of this image will directly impact the final result of the mask combination.

image2

This parameter represents the second mask image to be combined. Similar to image1, it is a crucial input for the combination operation. The interaction between image1 and image2 based on the selected operation will determine the final output.

op

This parameter specifies the operation to be performed on the two input masks. The available options are:

  • "union (max)": Combines the masks by taking the maximum value at each pixel.
  • "intersection (min)": Combines the masks by taking the minimum value at each pixel.
  • "difference": Subtracts image2 from image1.
  • "multiply": Multiplies the values of the two masks.
  • "multiply_alpha": Multiplies the alpha channel of image1 by image2.
  • "add": Adds the values of the two masks.
  • "greater_or_equal": Sets the output to 1 where image1 is greater than or equal to image2, otherwise 0.
  • "greater": Sets the output to 1 where image1 is greater than image2, otherwise 0. The choice of operation will significantly affect the resulting mask.

clamp_result

This parameter determines whether the result should be clamped between 0 and 1. If set to "yes", the output values will be restricted to this range, ensuring that the mask values remain valid.

round_result

This parameter specifies whether the result should be rounded to the nearest integer. If set to "yes", the output values will be rounded, which can be useful for creating binary masks.

Combine Masks Output Parameters:

result

The output parameter result is the combined mask image resulting from the specified operation on image1 and image2. This mask can be used in further processing or directly in your artwork, depending on the chosen operation and input parameters.

Combine Masks Usage Tips:

  • Experiment with different operations (op parameter) to see how they affect the combined mask. Each operation can produce vastly different results, so try multiple options to find the one that best suits your needs.
  • Use the clamp_result parameter to ensure that the output mask values stay within a valid range, especially if you are performing operations that might result in values outside the 0-1 range.
  • The round_result parameter is useful when you need a binary mask. Enable this option to convert the combined mask into a binary format, which can be helpful for certain types of image processing tasks.

Combine Masks Common Errors and Solutions:

"RuntimeError: The size of tensor a (X) must match the size of tensor b (Y)"

  • Explanation: This error occurs when the input masks image1 and image2 have different dimensions.
  • Solution: Ensure that both input masks have the same dimensions before combining them. You can resize one of the masks to match the other using an image processing tool or node.

"ValueError: Invalid operation specified"

  • Explanation: This error occurs when an invalid operation is passed to the op parameter.
  • Solution: Check the op parameter and ensure that it is set to one of the valid options: "union (max)", "intersection (min)", "difference", "multiply", "multiply_alpha", "add", "greater_or_equal", or "greater".

"TypeError: Expected input to be a tensor"

  • Explanation: This error occurs when the input images are not in the expected tensor format.
  • Solution: Ensure that the input images are properly converted to tensors before passing them to the Combine Masks node. Use appropriate conversion functions if necessary.

Combine Masks Related Nodes

Go back to the extension to check out more related nodes.
Masquerade Nodes
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.