KJNodes/maskinggenerated

Draw Mask On Image(DrawMaskOnImage)

This node technically receives image and mask tensors, and applies color to the masked area using an alpha blending mechanism.

Draw Mask On Image

image
mask
images
color
0, 0, 0
device
cpu
KJNodes

The Draw Mask On Image node technically receives image and mask tensors and applies color to the masked area using an alpha blending mechanism.

The Draw Mask On Image node is an image processing tool whose core function is to draw a mask onto an input image with a specified color. It supports visualizing mask regions on images, commonly used for checking or previewing mask coverage.

Node Functionality

This node technically receives image and mask tensors and applies color to the masked area using an alpha blending mechanism. It supports multiple color formats, including RGB (e.g., "255, 0, 0"), RGBA (e.g., "255, 0, 0, 128"), and hexadecimal format (e.g., "#FF0000"). The node automatically handles mismatches in dimensions and batch sizes between the image and mask to ensure smooth operation.

Node Parameter Description - Draw Mask On Image

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
imageIMAGEYes--image (input parameter): Receives the original image on which the mask needs to be drawn, in the standard IMAGE type tensor format.
maskMASKYes--mask (input parameter): Receives the mask to be drawn onto the image, in the MASK type tensor format. Its white areas will be colored.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
colorSTRINGYes0, 0, 0-Color as RGB/RGBA values in range 0-255 or 0.0-1.0, separated by commas. Ex: 255, 0, 0, 128
deviceCOMBONocpu"cpu", "gpu"-

Output

Parameter NameData TypeDescription
imagesIMAGEimages (output parameter): Outputs a new image with the colored mask overlaid.

Usage Scenarios

In practical applications, this node is often used in image editing or inpainting workflows. For example, after generating a mask to identify an area of an image that needs inpainting, this node can be used to overlay the mask onto the original image with a semi-transparent red color. This allows for intuitive confirmation of whether the target area is accurate before sending the result to an inpainting node for processing.

Notes

Please note that the format of the color string must strictly adhere to the requirements. Values must be separated by commas and should not contain any characters other than spaces; otherwise, parsing errors may occur. Additionally, selecting the "gpu" device can accelerate processing, but it requires ensuring that the runtime environment supports CUDA.

The Draw Mask On Image node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…