PettyPaint Control Net To Masking
Slice an OpenPose ControlNet image into head, torso, and leg masks
- head
- torso
- leg
Here's the trick this node exploits: an OpenPose ControlNet image isn't a drawing, it's a color-coded map. Every joint and bone gets a specific palette color - nose is #FF0000, neck is #FF5500, and so on through the whole skeleton. If you've generated a pose-controlled image and you want to region it - re-render just the head, just the torso, just the legs - you can extract those regions straight from the pose map's colors. That's what PettyPaintControlNetToMasking does: it reads the OpenPose-style pose image, groups the palette colors into head, torso, and leg sets, and returns three images, one per region.
It's a clever idea and it sits in exactly the right place conceptually: the KB's ControlNet panel describes how pose maps carry structure, and this node turns that structure into reusable masks for regional conditioning or inpainting. If you've ever wanted to "fix just the hands" by targeting the region a pose map already knows about, this is the shortcut.
How it works
It loads the pose image, then for each body part it scans for the known OpenPose joint/bone colors (head, torso, and leg color sets defined in the node's source), masks out everything else, and dilates the remaining region by expansion_size pixels using an elliptical kernel. The tolerance slider widens the color match so near-palette colors also count. Output is the classic head / torso / leg trio.
But - and this is where the gotchas stack up - read the inputs carefully, because nothing about them matches what you probably assumed.
The inputs and outputs
image- this is a STRING file path, not an IMAGE tensor. The node reads it from disk with OpenCV. You need a node that outputs a file path (like the pack's own PettyPaintLoadImage or a path string), not a Load Image output.expansion_size(1–100, default 1) - how many pixels the extracted region is dilated.tolerance(1–100, default 1) - color matching tolerance.- Outputs:
head,torso,leg- three IMAGEs, one per region.
Installing it
Ships in the petty-paint pack:
cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node
Restart ComfyUI, or use ComfyUI Manager and search "petty-paint-comfyui-node". Note the real dependency: this node imports cv2 (OpenCV) at module load, and it is not in the pack's requirements - it works only if your ComfyUI environment already has opencv-python installed, and if it doesn't, the whole pack fails to import. Check python -c "import cv2" before you go hunting.
Common issues
Three honest warnings, and they're real ones from the source code. First, the Windows-only hardcoded path: the node writes its result to d:\temp.png and reloads it - that path only exists on Windows, so on Linux or macOS this node will crash. Second, the STRING file-path input surprises everyone: wire an IMAGE into it and it fails. Third, the OpenCV dependency isn't declared anywhere in the pack's requirements. Net assessment: clever idea, but it's a Windows-and-OpenCV-only, path-based implementation of what most people would do more portably with a color-to-mask node on the IMAGE tensor directly. If you're not on Windows, treat this one as a read-only curiosity.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | STRING | — | |
| expansion_size | INT | 11–100 | — |
| tolerance | INT | 11–100 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| head | IMAGE | — |
| torso | IMAGE | — |
| leg | IMAGE | — |