BlurFusionForegroundEstimation
Fix the colour bleed in any cutout — no model required
- images
- masks
- image
- mask
Here's the thing nobody tells you about background removal: a perfect mask is only half the job. The other half is the colour under the mask. Hair and semi-transparent edges pick up the background's colour as they're cut, so you get a clean alpha and a subject that still looks pasted-on. BlurFusionForegroundEstimation is the stage that fixes that - and unlike everything else in this pack, it doesn't need a model at all.
It's the standalone version of the "Advanced" half of RembgByBiRefNetAdvanced. Give it an image and a mask from any source - BiRefNet, rembg, SAM, a mask you drew by hand - and it estimates the true foreground colour and returns a decontaminated cutout.
How it works
This is Photoroom's fast-foreground-estimation (the node description links the original implementation). The math is a two-pass blur-fusion, which is why the node has two blur settings:
- Blur the alpha mask to get a soft transition.
- Estimate what the foreground and background each look like underneath that blur - the blurred foreground is the masked image blurred and divided by the blurred alpha.
- Reconstruct the clean foreground: where the mask says "subject", pull the colour out of the image; where it says "background", let the estimated background colour show. The result is a subject whose edge pixels no longer glow with the old backdrop's hue.
Pass one uses a coarse blur_size (default 90) to scrub the broad bleed; pass two uses a fine blur_size_two (default 6) to keep the actual edges sharp. In this pack the blur runs through OpenCV (cv2.blur), which is why opencv-python is a hard dependency.
The pack forces the blur radii to odd numbers internally (adds 1 if you give it an even one) - kernel sizes for this kind of blur are conventionally odd, and the author made it automatic so you don't have to think about it.
Inputs and outputs
- images - your
IMAGEtensor. - masks - a
MASKtensor, same batch size as the images. The one hard error this node throws: batch mismatch, so if you get a "must have the same batch size" error, that's it. - blur_size / blur_size_two - the coarse and fine blur radii described above.
blur_sizeup = more aggressive background-colour removal (and more risk of smearing fine detail); down = cleaner detail but a stubborn fringe. - fill_color / color - with
fill_coloron, the background becomes a solid RGB colour (coloris the 24-bit value, 0 = black) instead of transparency. Handy for previews or flat-colour composites.
Outputs are image (RGBA when fill_color is off, flat RGB when it's on) and mask (the mask you fed in, passed through unchanged).
Install
Same pack, one install for all six nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/ComfyUI_BiRefNet_ll.git
cd ComfyUI_BiRefNet_ll
pip install -r requirements.txt # numpy, opencv-python, timm
# restart ComfyUI
ComfyUI Manager users: search ComfyUI_BiRefNet_ll.
Notes from the field
- This is the same foreground estimator
RembgByBiRefNetAdvancedcalls internally - if you've used that node, you've used this one's algorithm. What's genuinely useful here is the standalone path: any mask you already trust can be cleaned up by this node without re-running a segmentation model. - It's the "Approximate" fast estimation, not the heavy matting-grade one. A finer (and slower) alternative exists in the ecosystem, but this version runs in a couple of blur operations - effectively free next to the segmentation itself.
- Edges still look off after cranking
blur_size? Then the problem is the mask, not the colour: if your mask is wrong at semi-transparent edges (the classic hard-mask-on-glass case), no colour estimation can save it. Use the Matting weights upstream instead.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| masks | MASK | — | |
| blur_size | INT | 901–255 | — |
| blur_size_two | INT | 61–255 | — |
| fill_color | BOOLEAN | false | — |
| color | INT | 00–16777215 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |