ComfyUI > Nodes > ComfyUI-UniversalToolkit > Mask Sub (UTK)

ComfyUI Node: Mask Sub (UTK)

Class Name

MaskSub_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

Mask Sub (UTK) Description

Performs pixel-wise subtraction between two masks, clamping results between 0 and 1 for validity.

Mask Sub (UTK):

The MaskSub_UTK node is designed to perform pixel-wise subtraction between two masks, which are essentially binary or grayscale images used to define areas of interest or exclusion in image processing tasks. This node is particularly useful in scenarios where you need to differentiate between two mask layers, effectively highlighting the differences by subtracting one mask from another. The operation is batch-supported, meaning it can handle multiple masks simultaneously, making it efficient for processing large datasets. The result of the subtraction is clamped between 0 and 1, ensuring that the output remains within a valid range for mask values. This clamping is crucial as it prevents negative values, which are not meaningful in the context of masks, and ensures that the output can be directly used in subsequent image processing tasks.

Mask Sub (UTK) Input Parameters:

mask1

mask1 is the first input mask for the subtraction operation. It serves as the base mask from which the second mask (mask2) will be subtracted. This parameter should be a binary or grayscale image, typically represented as a tensor, where each pixel value indicates the presence or absence of a feature. The shape of mask1 must match that of mask2 to ensure a valid subtraction operation. There are no specific minimum, maximum, or default values for this parameter, but it is essential that the mask is correctly formatted and aligned with mask2 for accurate results.

mask2

mask2 is the second input mask that will be subtracted from mask1. Like mask1, this parameter should also be a binary or grayscale image represented as a tensor. The primary role of mask2 is to define the areas that will be subtracted from mask1, effectively removing or reducing the influence of these areas in the resulting mask. The shape of mask2 must be identical to that of mask1, and it should be properly aligned to ensure the subtraction operation is performed correctly. As with mask1, there are no specific minimum, maximum, or default values, but proper formatting and alignment are crucial.

Mask Sub (UTK) Output Parameters:

mask

The output parameter mask is the result of the pixel-wise subtraction between mask1 and mask2. This output is a new mask where each pixel value represents the difference between the corresponding pixels in the input masks, clamped to a range between 0 and 1. This clamping ensures that the output remains a valid mask, with no negative values, which are not meaningful in this context. The resulting mask can be used in further image processing tasks, such as compositing, filtering, or analysis, where the differences between the original masks are of interest.

Mask Sub (UTK) Usage Tips:

  • Ensure that both mask1 and mask2 have the same dimensions and are properly aligned to avoid errors and ensure accurate subtraction results.
  • Use this node to highlight differences between two mask layers, which can be particularly useful in tasks such as change detection or feature extraction in image processing workflows.
  • Consider normalizing your input masks to ensure they are within the expected range before performing the subtraction to avoid unexpected results.

Mask Sub (UTK) Common Errors and Solutions:

输入的两个MASK尺寸不一致

  • Explanation: This error occurs when the input masks mask1 and mask2 have different dimensions, which prevents the node from performing the subtraction operation.
  • Solution: Ensure that both input masks have the same shape and dimensions before passing them to the node. You may need to resize or crop one of the masks to match the other.

Mask Sub (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.

Mask Sub (UTK)