BlurFusionForegroundEstimationForBen
The defringing step that makes cutouts stop looking like cutouts
- images
- masks
- image
- mask
The quiet workhorse of this pack, and the reason its cutouts don't carry that telltale grey halo. BlurFusionForegroundEstimationForBen is a foreground color estimator: give it an image and a mask, and it recovers the actual subject color where the mask edge is soft, so white fur stays white instead of picking up a fringe of whatever background it sat on.
The "ForBen" in the name is a bit of a lie, and a happy one - this node is model-agnostic. It doesn't need a BEN model at all, just any image and any mask. The node description points at Photoroom's fast-foreground-estimation repo, and the code is a faithful port. The mechanism is blur-fusion matting:
- Gaussian-blur the alpha mask at a large radius (
blur_size, default 91) to build a rough background estimate from the blurred image's non-subject region. - Solve for the foreground with the correction
F = blurred_F + α·(I − α·blurred_F − (1−α)·blurred_B)- one step that pushes the background bleed back out of the edges. - Do it again at a small radius (
blur_size_two, default 7) to keep the fine edge detail intact.
That two-pass structure is the whole idea: the big blur kills the halo, the small blur preserves the crisp boundary. The code enforces odd radii (it bumps even values up by 1), and the inputs step by 2 to match.
Inputs: images, masks, then the knobs. blur_size (91) handles the coarse halo removal; blur_size_two (7) handles edge detail. Fine hair? Drop the big blur to ~21–31. A product shot with soft edges? The defaults are right. fill_color (false) and color (an int from 0 to 16777215, i.e. 0xFFFFFF in RGB) are the bonus: flip fill_color on and the background becomes a solid color instead of transparency, which is handy for mockups on a brand backdrop.
Outputs: image (RGBA unless you're filling, then solid-background) and mask (passed through unchanged).
Where people get burned: the images and masks must share a batch size - the code raises "images and masks must have the same batch size" if you feed a batch of images one mask. And it wants a soft mask: a hard binary mask works (that's exactly how RembgByBen uses it), but a fractional-alpha matte gives noticeably better defringing.
Use it standalone with any segmentation node - BiRefNet, InSPyReNet, whatever - as the cleanup step after the cutout. Install is the pack standard: clone, pip install -r requirements.txt, restart ComfyUI.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| masks | MASK | — | |
| blur_size | INT | 911–255 | — |
| blur_size_two | INT | 71–255 | — |
| fill_color | BOOLEAN | false | — |
| color | INT | 00–16777215 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |