Polygon Mask
Draw shapes on any image, get a real mask out the back
- image
- color
- masked_image
- raw_mask
- text
Want to mark regions on an image - "inpaint this wall", "don't touch this object", "this is where the counter goes" - without painting a freehand mask? Polygon Mask gives you a proper polygon editor right inside the node: click points on the image, get closed shapes, and out the back come three things you can actually use - the image with the overlays composited on it, a clean black-and-white mask at original resolution, and a text pass-through you can use to label what each region means.
It's the "get that mask in so many ways" idea from the KB's masking doc applied to geometry instead of segmentation. A polygon mask is the most explicit, least magical mask you can produce: you drew it, so you know exactly what it covers. That makes it great for controlled inpainting regions, layout planning in arch-viz or product shots, and feeding region hints to promptable segmentation.
How it works
You feed an IMAGE in; the node renders it as an editable canvas in its panel. The editor's polygon state lives in a polygon_data string (an internal field the editor manages - leave it alone). On execute, the node draws the polygons onto the image at the chosen opacity and width, and separately rasterizes the same polygons into a hard black/white MASK at the original image resolution - so the mask matches your source even if the preview was scaled for editing.
Three behaviors make it feel finished. First, it can read the polygon selection straight off a connected Load Image node in the same workflow, so you're not re-drawing. Second, for image sources that aren't a Load Image, the node shows an execution preview that doesn't overwrite your persistent state until you explicitly apply it - you can try a polygon, look at the result, and keep or discard. Third, when you swap in a different image, valid polygons are kept, and if the resolution changed, vertices are scaled proportionally so your regions don't drift off their targets.
The inputs that matter
image- the image to annotate. Required.vertex_count(3–50, default 3) - how many corners a new polygon gets. Lower for triangles, higher for anything roundish.colorandfill_opacity(0–100, default 35) - overlay appearance. The fill is semi-transparent so you can see the image under it; crank to 100 to preview the mask coverage.outline_width(0–20, default 3) - the polygon edge stroke.text- multiline text that passes straight through to thetextoutput. Handy for labeling regions or carrying notes to a downstream prompt builder.
The outputs: masked_image (overlay composited), raw_mask (the b/w mask, wire this into inpaint or region nodes), and text.
How to install it
Part of the DAELab pack. ComfyUI Manager, search "ComfyUI-DAELab-Custom-Nodes-Library", or:
cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library
then restart. No models, no dependencies beyond ComfyUI itself. This is a V3 node and a heavy front-end one - the polygon editor is all in web/, so install the full repo or you'll get a backend node with no drawing canvas. Keep ComfyUI Core current (No module named 'comfy_api' → update Core, don't pip).
Common issues & troubleshooting
"I drew polygons but the mask output is empty." Your polygons are in the editor but the polygon_data state didn't reach the backend - happens if the node executed before the editor saved, or you're running the workflow from a viewer that stripped node properties. Re-apply and re-run.
"The overlay shows but raw_mask doesn't match." Check fill_opacity/outline_width - the mask is the geometric fill of the polygons, and a tiny outline or transparent fill can make a mask that looks different from the pretty overlay. That's expected.
"Polygons are in the wrong place after changing the image." Vertices rescale proportionally to resolution - if the new image has a different aspect ratio, the regions shift. Re-apply the polygons for images with different framing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| vertex_count | INT | 33–50 | — |
| color | COLOR | #FF0000 | — |
| fill_opacity | INT | 350–100 | — |
| outline_width | INT | 30–20 | — |
| polygon_data | STRING | Internal polygon state managed by the Polygon Mask editor. | |
| text | STRING | Multiline text passed through to the text output. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| masked_image | IMAGE | — |
| raw_mask | MASK | — |
| text | STRING | — |