ComfyUI > Nodes > ComfyUI 1hewNodes > Mask Fill Hole

ComfyUI Node: Mask Fill Hole

Class Name

1hew_MaskFillHole

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 Fill Hole Description

Fills holes in image masks to ensure continuous shapes for accurate image processing.

Mask Fill Hole:

The 1hew_MaskFillHole node is designed to process image masks by filling in holes within the mask, ensuring a continuous and complete shape. This node is particularly useful in image processing tasks where masks are used to isolate or highlight specific areas of an image, such as in segmentation or compositing. By filling holes, the node helps maintain the integrity of the mask, preventing unwanted gaps that could affect subsequent image processing operations. The node operates by converting the mask into a binary format, identifying and filling holes using a binary structure, and then optionally inverting the mask if required. This functionality is crucial for artists and designers who need precise control over mask shapes to achieve desired visual effects.

Mask Fill Hole Input Parameters:

mask

The mask parameter is the primary input for the node, representing the image mask that you want to process. This mask is typically a tensor that contains pixel values indicating the areas of interest within an image. The node expects this input to be in a format that can be converted into a binary mask, where pixel values above a certain threshold are considered part of the mask. The mask's dimensions should be compatible with the node's processing capabilities, and it should be provided as a PyTorch tensor.

invert_mask

The invert_mask parameter is a boolean input that determines whether the resulting filled mask should be inverted. When set to True, the node will invert the mask after filling the holes, effectively swapping the masked and unmasked areas. This can be useful in scenarios where you need to highlight the areas outside the original mask. The default value for this parameter is False, meaning the mask will not be inverted unless explicitly specified.

Mask Fill Hole Output Parameters:

mask

The output mask parameter is the processed image mask with holes filled. This output is a PyTorch tensor that retains the same dimensions as the input mask but with any internal gaps closed, resulting in a more cohesive and continuous mask. This filled mask can be used in further image processing tasks, ensuring that the areas of interest are accurately represented without interruptions.

Mask Fill Hole Usage Tips:

  • To ensure optimal performance, make sure your input mask is properly formatted and contains clear distinctions between masked and unmasked areas. This will help the node accurately identify and fill holes.
  • If you need to highlight areas outside the original mask, consider using the invert_mask parameter to invert the filled mask, which can be particularly useful in compositing tasks.

Mask Fill Hole Common Errors and Solutions:

"Input mask is not a tensor"

  • Explanation: This error occurs when the input mask is not provided as a PyTorch tensor, which is the expected format for processing.
  • Solution: Ensure that the input mask is converted to a PyTorch tensor before passing it to the node. You can use torch.from_numpy() if your mask is initially in a NumPy array format.

"Mask dimensions are incompatible"

  • Explanation: This error indicates that the input mask does not have the expected dimensions, which can prevent the node from processing it correctly.
  • Solution: Verify that your mask has the correct dimensions, typically a 2D or 3D tensor, and adjust it if necessary. You may need to use functions like unsqueeze() to add dimensions if required.

Mask Fill Hole 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 Fill Hole