Nodes/ComfyUI-DAELab-Custom-Nodes-Library/Badge 8.7 Boundary Composite (DAELab)
ComfyUI Node

Badge 8.7 Boundary Composite (DAELab)

The node that cleans up GPT's messy badge edges, one pixel band at a time

By TeutonicMepheles·Created 4 months ago·Updated 6 days ago· 0
Badge 8.7 Boundary Composite (DAELab)
  • original
  • previous_master
  • edit_candidate
  • edit_mask
  • coverage
  • IMAGE

What this is for

You asked an instruction-editing model to swap the material on one region of a badge, it did the middle of the region beautifully, and then it left you a two-pixel halo of the old surface color right along the edge. Feathering the mask doesn't fix it - a blur just averages your new material with the old one you were trying to get rid of. This node does the unglamorous thing instead: it works out how much of each edge pixel was actually the old material, then rebuilds that pixel from the new interior color and the background behind it.

It's a compositor, not a generator. No model, no API call, no money. Badge 8.7 Boundary Composite is one of the deterministic stages the DAELab badge workflow drops around the paid GPT-Image call so the expensive part can be a bit sloppy and still come out clean.

How it works

Five inputs, and the order matters more than the names suggest. original is the flat artwork you started from, previous_master is the composite you had before this edit, edit_candidate is the raw model output, edit_mask is the region you paid to edit, and coverage is an alpha-style mask saying how much of each edge pixel belongs to the new surface.

Inside the mask it finds the "core" - pixels at least two pixels in from the boundary - and uses that core as the new foreground color. For pixels in the mixed band at the edge (within two pixels of the boundary, within three of the core), it measures how far each observed pixel sits along the color line between the old interior and the old background. When that measurement is trustworthy - long enough color separation, small residual - it takes the measured fraction as coverage. Everything else keeps the coverage you passed in.

Then it rebuilds those mixed pixels in linear light: new interior × coverage + previous master × (1 − coverage), converted back to sRGB. Sharp, fully covered pixels aren't touched. Mixed pixels with no reliable interior sample nearby - thin gold lines, the case the author's own docs call out as still failing - are left conservative rather than interpolated from somewhere far away.

Two guarantees are exact, and they're the reason to use it:

  • Every pixel outside edit_mask comes from previous_master, bit for bit.
  • Pixels where the candidate already equals the original stay exactly as the original.

So the worst case is "my new material has a slightly odd edge". Never "my whole badge shifted".

The inputs that matter

For a beginner wiring this by hand, edit_mask and coverage are the ones that will bite you. edit_mask is the region you paid to edit. coverage must be a real float mask in 0–1, sampled properly (the pack's region-geometry service produces it with 4× supersampled signed distance, which is where the smooth values come from) - feed it a hard 0/1 mask and you get the same aliased edge back.

The node is picky in a useful way: all three images must share identical dimensions, the masks must match the canvas, and coverage must contain only finite values in [0,1] or it throws. That's validation, not a bug. It exists because a mismatched tensor here silently produces a badge-sized smear.

Output is one IMAGE. Wire it into your save/preview, or into the next stage's previous_master.

Install

Standard for this pack - ComfyUI Manager, search the pack title, or:

cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library.git
# restart ComfyUI

No extra model downloads. The badge nodes lean on scipy, which the pack's requirements.txt doesn't declare (python-docx, openpyxl, pdfplumber are there for the storyboard importer, not for this). ComfyUI core normally ships scipy already, so most people never notice.

Where people get burned

The honesty in the pack's own docs is worth repeating: this handles mixed edge pixels, not region recognition. Complex thin gold-line boundaries can keep a sliver of the old color, and the fix is upstream - tighten the selection, raise the region inset so you're editing inside the line - not a second pass through this node.

Second trap: feeding a coverage mask that isn't actually coverage. If it's a binary selection, the node's own measurement does all the work and looks like it's doing nothing on soft edges.

If scipy genuinely is missing you'll get ModuleNotFoundError: No module named 'scipy' at load, and the whole pack's import fails with it:

ComfyUI/python_embeded/python.exe -m pip install scipy numpy

Enamel pins, patches, coins, nameplates, any hard-surface product shot where a paid edit has to respect a boundary - that's the use case. If you're masking a photo of a person, this pack's badge assumptions (1024 canvas, flat art) will feel like a straitjacket, and ordinary inpainting with a bit of blur is more your speed.

CategoryDAELab/Badge

Inputs (5)

NameTypeDefaultDescription
originalIMAGE—
previous_masterIMAGE—
edit_candidateIMAGE—
edit_maskMASK—
coverageMASK—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—