ComfyUI > Nodes > KJNodes for ComfyUI > Color To Mask

ComfyUI Node: Color To Mask

Class Name

ColorToMask

Category
KJNodes/masking
Author
kijai (Account age: 2192days)
Extension
KJNodes for ComfyUI
Latest Updated
2024-06-25
Github Stars
0.35K

How to Install KJNodes for ComfyUI

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

Color To Mask Description

Convert specified RGB color in image to mask, isolate colors, define target color, threshold, invert mask, batch processing.

Color To Mask:

The ColorToMask node is designed to convert a specified RGB color value within an image into a mask. This is particularly useful for isolating specific colors in an image and creating masks that can be used for further image processing or artistic effects. The node allows you to define the target color and a threshold to determine how closely colors in the image must match the target color to be included in the mask. Additionally, you can choose to invert the mask, turning the selected color areas into the background and vice versa. The node also supports batch processing, enabling you to handle multiple images simultaneously, with the per_batch parameter controlling the number of images processed at once.

Color To Mask Input Parameters:

images

This parameter accepts the input images that you want to process. The images should be in a format that the node can interpret, typically as tensors.

invert

This boolean parameter determines whether the mask should be inverted. If set to True, the areas matching the target color will be turned into the background, and the rest of the image will become the mask. The default value is False.

red

This integer parameter specifies the red component of the target RGB color. It ranges from 0 to 255, with a default value of 0.

green

This integer parameter specifies the green component of the target RGB color. It ranges from 0 to 255, with a default value of 0.

blue

This integer parameter specifies the blue component of the target RGB color. It ranges from 0 to 255, with a default value of 0.

threshold

This integer parameter defines the tolerance level for color matching. Colors within this threshold distance from the target color will be included in the mask. It ranges from 0 to 255, with a default value of 10.

per_batch

This integer parameter controls the number of images processed at once in batch mode. It ranges from 1 to 4096, with a default value of 16.

Color To Mask Output Parameters:

MASK

The output is a mask where the areas matching the specified RGB color (within the given threshold) are highlighted. The mask is a tensor with values clamped between 0.0 and 1.0, representing the masked areas.

Color To Mask Usage Tips:

  • To isolate a specific color in an image, set the red, green, and blue parameters to the desired RGB values and adjust the threshold to fine-tune the mask.
  • Use the invert parameter to quickly switch between highlighting the target color and the rest of the image.
  • For processing large batches of images, adjust the per_batch parameter to optimize performance based on your system's capabilities.

Color To Mask Common Errors and Solutions:

"Input images are not in the correct format"

  • Explanation: The input images provided are not in a format that the node can process.
  • Solution: Ensure that the input images are tensors and are correctly formatted before passing them to the node.

"Threshold value out of range"

  • Explanation: The threshold parameter is set to a value outside the acceptable range of 0 to 255. - Solution: Adjust the threshold parameter to a value within the specified range.

"Batch size exceeds limit"

  • Explanation: The per_batch parameter is set to a value higher than the maximum allowed limit of 4096.
  • Solution: Reduce the per_batch parameter to a value within the acceptable range of 1 to 4096.

Color To Mask Related Nodes

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