ComfyUI > Nodes > ComfyUI > ThresholdMask

ComfyUI Node: ThresholdMask

Class Name

ThresholdMask

Category
mask
Author
ComfyAnonymous (Account age: 598days)
Extension
ComfyUI
Latest Updated
2024-08-12
Github Stars
45.85K

How to Install ComfyUI

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

ThresholdMask Description

Converts input mask to binary mask based on threshold for isolating image areas with precise control.

ThresholdMask:

The ThresholdMask node is designed to convert an input mask into a binary mask based on a specified threshold value. This node is particularly useful for AI artists who need to isolate certain areas of an image or mask by setting a threshold that determines which parts of the mask are kept and which are discarded. By comparing each pixel value in the mask to the threshold, the node generates a new mask where pixels above the threshold are set to one (white) and those below are set to zero (black). This functionality is essential for tasks that require precise control over mask regions, such as image compositing, masking effects, and selective image processing.

ThresholdMask Input Parameters:

mask

The mask parameter is the input mask that you want to threshold. This mask is typically a grayscale image where different pixel values represent different levels of intensity. The node will process this mask to create a binary mask based on the specified threshold value.

value

The value parameter is a floating-point number that sets the threshold level for the mask. Pixels in the input mask with values greater than this threshold will be set to one in the output mask, while those with values less than or equal to the threshold will be set to zero. The value parameter ranges from 0.0 to 1.0, with a default value of 0.5. This allows for fine-tuning the threshold to achieve the desired masking effect.

ThresholdMask Output Parameters:

mask

The output mask is the binary mask generated by applying the threshold to the input mask. In this binary mask, pixels with values greater than the specified threshold are set to one (white), and those with values less than or equal to the threshold are set to zero (black). This output mask can be used in various image processing tasks where a clear distinction between masked and unmasked areas is required.

ThresholdMask Usage Tips:

  • To isolate brighter areas of an image, set the value parameter closer to 1.0. This will ensure that only the brightest pixels are included in the output mask.
  • For tasks that require masking darker areas, set the value parameter closer to 0.0. This will include more of the darker pixels in the output mask.
  • Experiment with different threshold values to achieve the best results for your specific use case. Small adjustments can significantly impact the final mask.

ThresholdMask Common Errors and Solutions:

"Input mask is not provided"

  • Explanation: This error occurs when the mask parameter is not supplied to the node.
  • Solution: Ensure that you provide a valid mask input to the node before executing it.

"Threshold value out of range"

  • Explanation: This error occurs when the value parameter is set outside the allowed range of 0.0 to 1.0.
  • Solution: Adjust the value parameter to be within the range of 0.0 to 1.0.

"Invalid mask format"

  • Explanation: This error occurs if the input mask is not in the expected format or data type.
  • Solution: Verify that the input mask is a valid grayscale image and conforms to the expected format required by the node.

ThresholdMask Related Nodes

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