ComfyUI > Nodes > ComfyUI_XISER_Nodes > Invert Mask

ComfyUI Node: Invert Mask

Class Name

XIS_InvertMask

Category
XISER_Nodes/Image_And_Mask
Author
grinlau18 (Account age: 944days)
Extension
ComfyUI_XISER_Nodes
Latest Updated
2026-03-20
Github Stars
0.03K

How to Install ComfyUI_XISER_Nodes

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

Invert Mask Description

Inverts input masks to swap masked and unmasked regions for precise image compositing tasks.

Invert Mask:

The XIS_InvertMask node is designed to perform an inversion operation on input masks, which are typically used in image processing to define areas of interest or exclusion. This node is particularly useful in scenarios where you need to reverse the areas defined by a mask, effectively swapping the masked and unmasked regions. By inverting the mask, you can easily toggle between focusing on the foreground and background elements of an image. This capability is essential for tasks such as image compositing, where precise control over which parts of an image are visible or affected by subsequent operations is crucial. The node ensures that the inversion process is handled efficiently and accurately, maintaining the integrity of the mask's dimensions and values.

Invert Mask Input Parameters:

mask

The mask parameter is the primary input for the XIS_InvertMask node. It represents the mask that you wish to invert. This mask is typically a tensor that defines which parts of an image are selected or excluded. The mask should be in a valid format, usually a 2D or 3D tensor, where the values range between 0 and 1. A value of 0 indicates a fully transparent area, while a value of 1 indicates a fully opaque area. The inversion process will swap these values, turning transparent areas opaque and vice versa. This parameter is crucial as it directly influences the outcome of the inversion operation.

invert_mask

The invert_mask parameter is a boolean input that determines whether the mask should be inverted. By default, this parameter is set to False, meaning the mask will not be inverted unless explicitly specified. When set to True, the node will perform the inversion operation, effectively reversing the mask's values. This parameter provides flexibility, allowing you to control the inversion process dynamically based on your specific needs.

Invert Mask Output Parameters:

output_mask

The output_mask is the result of the inversion operation performed by the XIS_InvertMask node. It is a tensor that mirrors the dimensions of the input mask but with inverted values. This means that areas that were previously masked (opaque) will become unmasked (transparent), and vice versa. The output mask is crucial for subsequent image processing tasks, as it defines the new areas of interest or exclusion based on the inversion operation. The precision of the output is maintained by ensuring the values remain within the valid range of 0 to 1.

Invert Mask Usage Tips:

  • Ensure that the input mask is correctly formatted and within the valid range of 0 to 1 to avoid unexpected results during inversion.
  • Use the invert_mask parameter to toggle the inversion operation dynamically, allowing for flexible control over the mask processing workflow.
  • Consider the dimensions of the input mask and ensure they match the expected input size for your specific application to maintain consistency in the output.

Invert Mask Common Errors and Solutions:

Empty mask batch received

  • Explanation: This error occurs when the input mask batch is empty, meaning no valid mask data was provided for processing.
  • Solution: Verify that the input mask is correctly loaded and not empty before passing it to the node. Ensure that the data source is correctly configured and that the mask is properly formatted.

Mask has invalid dimensions: <mask.shape>

  • Explanation: This error indicates that the input mask has dimensions that are not supported by the node, such as a shape that is neither 2D nor 3D.
  • Solution: Check the dimensions of the input mask and ensure it conforms to the expected format. Adjust the mask dimensions if necessary to match the required input size.

Invert Mask Related Nodes

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

Invert Mask