KJNodes/masking/generategenerated

Create Shape Mask On Path(CreateShapeMaskOnPath)

This node determines the center position of each shape by parsing the input JSON-formatted coordinate string, and draws them on a canvas of specified width and height based on the user-selected shape type (circle, square, triangle) and size parameters.

Create Shape Mask On Path

mask
mask_inverted
shape
circle
coordinates
STRING
frame_width
512
frame_height
512
shape_width
128
shape_height
128
size_multiplier
1
KJNodes

The Create Shape Mask On Path node determines the center position of each shape by parsing the input JSON-formatted coordinate string. It then draws the shapes on a canvas of specified width and height based on the user-selected shape type (circle, square, triangle) and size parameters.

The Create Shape Mask On Path node is used to batch-generate masks of specific shapes along a specified path on a canvas. It receives a series of coordinate points, draws preset geometric shapes at each point, and ultimately outputs the corresponding mask image and its inverted version.

Node Functionality

This node determines the center position of each shape by parsing the input JSON-formatted coordinate string. It then draws the shapes on a canvas of specified width and height based on the user-selected shape type (circle, square, triangle) and size parameters. It supports batch processing, allowing for the generation of multiple masks at once, and optionally scales each shape independently via a size multiplier.

Node Parameter Description - Create Shape Mask On Path

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
shapeCOMBOYescircle"circle", "square", "triangle"The type of shape to draw: circle, square, or triangle.
coordinatesSTRINGYes--coordinates (input parameter): Input a JSON-formatted string defining an array of coordinates for the center point of each shape, e.g., [[x1,y1], [x2,y2]].
frame_widthINTYes51216 - 4096 (step: 1)frame_width (input parameter): Sets the width of the output mask canvas. Valid range is 16 to 4096.
frame_heightINTYes51216 - 4096 (step: 1)frame_height (input parameter): Sets the height of the output mask canvas. Valid range is 16 to 4096.
shape_widthINTYes1288 - 4096 (step: 1)shape_width (input parameter): Sets the width of the drawn shape. Valid range is 8 to 4096.
shape_heightINTYes1288 - 4096 (step: 1)shape_height (input parameter): Sets the height of the drawn shape. Valid range is 8 to 4096.
size_multiplierFLOATNo[1.0]--

Output

Parameter NameData TypeDescription
maskMASKmask (output parameter): The output mask image, where the shape area is white.
mask_invertedMASKmask_inverted (output parameter): The output inverted mask image, where the shape area is black.

Usage Scenarios

This node is suitable for workflows that require creating precise masks for multiple specific areas. Examples include tracking and marking the positions of moving objects in video frames, or generating local processing regions for a series of points of interest (such as faces, buildings) in a large image. Users can directly input dynamically acquired coordinate data (e.g., from other analysis nodes) to automate the generation of mask sequences.

Notes

Please note that this node has been marked as "deprecated," meaning it may be removed or replaced by a node with superior functionality in future versions. The input coordinate string must be in strict JSON array format, e.g., [[100,200], [300,400]], otherwise it will cause a runtime error.

The Create Shape Mask On Path node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…