ComfyUI-KJNodes
Run ComfyUI Easily with InstaSD
Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:
- One-click deployment
- Any model, any node
- Powerful GPUs for rapid iteration
Available Nodes
ColorToMask
ColorToMask Node Documentation
Overview
The ColorToMask node is a utility within the ComfyUI-KJNodes suite designed to facilitate image processing by converting specific RGB color values within an image or batch of images into a mask. This process is particularly useful in workflows that require precise masking based on color information, supporting both single images and batch processing.
What This Node Does
The ColorToMask node takes an input image or batch of images and converts specified RGB color values into mask representations. The node is capable of handling batches of images, making it efficient for processing multiple images at once or even animations. The mask produced highlights areas of the image matching the specified color criteria, allowing for further image processing and analysis.
Inputs
The node accepts the following inputs:
-
images: The input image or batch of images that you want to convert to a mask. The images are expected to be in the form of tensors.
-
invert: A boolean option to invert the resulting mask. When
True, the mask will highlight areas not matching the color value. -
red: An integer (0-255) representing the red component of the target color.
-
green: An integer (0-255) representing the green component of the target color.
-
blue: An integer (0-255) representing the blue component of the target color.
-
threshold: An integer (0-255) specifying the tolerance level when matching the target color. A higher threshold allows for more color variation.
-
per_batch: An integer indicating the number of images processed concurrently from a batch. This parameter helps in managing processing load when dealing with large batches.
Outputs
The ColorToMask node produces the following output:
- MASK: A grayscale mask where matched color areas are highlighted (in white), and non-matched areas remain black. This mask is produced for each input image, aligning with the batch size of the input if applicable.
Usage in ComfyUI Workflows
The ColorToMask node is used within ComfyUI workflows where there is a need to isolate regions of an image based on specific color criteria. Common use cases include:
-
Selective Editing: Isolate parts of an image for targeted editing or transformation by using color-based masks.
-
Batch Processing: Efficiently process large numbers of images or frames from animations, applying consistent masking based on color.
-
Image Analysis: Highlight and analyze specific image features by extracting color-based regions, particularly useful in content analysis and computer vision tasks.
Special Features and Considerations
-
Batch Compatibility: The node efficiently handles batch processing, making it suitable for animations or large datasets, with the
per_batchparameter providing control over processing loads. -
Customizable Color Matching: Users can fine-tune the sensitivity of color matching using the
thresholdparameter, allowing for precise control over mask creation. -
Inversion Option: The ability to invert the mask allows for flexibility in applications, particularly useful when the areas of interest are defined by absence of a color.
-
Performance Considerations: When processing large image batches, users should adjust the
per_batchparameter according to their hardware capabilities to balance performance and speed.
In summary, the ColorToMask node is a versatile tool within the ComfyUI-KJNodes suite, offering robust color-based masking capabilities suitable for a wide range of image processing tasks.