RandomMask
Random blob masks for lazy inpaint experiments
- image
- image
- mask
Run this node and you get a fresh, wobbly white blob floating on black, sized to your image - and a brand-new one every time the graph executes. That sounds like a toy, and honestly it kind of is. But it's a useful toy: RandomMask is the fastest way to stress-test inpainting without drawing a mask by hand.
The classic move: run your image through, take the mask output into an inpaint workflow (Set Mask → sampler at controlled denoise), and let the model fill the random hole. Rerun and you get a different hole in a different spot. Great for feeling out what a checkpoint does with unconstrained space - how it textures empty regions, where it hallucinates, how it blends edges - or just for churning through "what if I regenerate this random middle chunk" ideas in a few seconds.
How it works
This one's a bit of a party trick under the hood. It builds a closed curve with a random number of points around a circle, jitters the radius about 10%, fills the resulting blob white, renders it black-on-white via matplotlib, resizes it to fit your image's smaller dimension, and centers it on a black background. Then padding and blur get applied like the rest of the pack.
The inputs that matter
image- only its dimensions matter. The content is ignored; you're just borrowing the size.noise(default 0, 0–1) - controls how jagged the blob's boundary is. Confusingly named: it's not pixel noise, it's the number of points in the curve (scaled from 20 up to 100). More points = wobblier, more organic edges. Zero still gives you a random blob, just a smoother one.padding(0–512) - a black margin added around the mask.blur(0–50) - softens the blob's edge, and this is the knob that matters most for inpaint seams: a little blur here is the difference between a clean fill and a hard artifact line.
Outputs
image- your original image, passed through untouched.mask- the blob. Wire it into any MASK input: Set Mask for inpainting, or Mask to Image if you want to look at it.
What to know before you build around it
There's no seed, and the node deliberately reports "always changed," so it re-rolls a fresh mask on every execution and forces everything downstream to re-run too. That's the feature - but it means you can't reproduce a mask, and an inpaint hooked to this will visibly re-generate on every run. If you need a repeatable or precisely-placed region, draw the mask yourself or threshold an image instead (see its sibling BinaryImageMask in the same pack).
Installing
RandomMask is one of five nodes in ComfyUI-TrollSuite by Øyvind (oyvindg on GitHub). The pack installs like any other custom node:
- ComfyUI Manager → search "ComfyUI-TrollSuite" → Install → restart.
- Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/oyvindg/ComfyUI-TrollSuite
then restart ComfyUI. Everything lands under the TrollSuite/mask and TrollSuite/image submenus.
The one real dependency trap
Most of the pack needs only ComfyUI's bundled torch + Pillow, but RandomMask secretly imports matplotlib to render the blob - and matplotlib is not in the pack's requirements and not guaranteed in a stock ComfyUI Python environment. If the node errors on first use with something about matplotlib, install it into the same Python your ComfyUI runs:
python -m pip install matplotlib # most installs (venv/system python)
ComfyUI/python_embeded/python.exe -m pip install matplotlib # Windows portable
then restart. Once that's in, it's the whole dependency story - no checkpoints, no model files, nothing else to fetch.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| noise | FLOAT | 0.00–1 | — |
| padding | INT | 00–512 | — |
| blur | FLOAT | 0.00–50 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |