Image Alpha Edge
Kill the matte fringe, keep the hair
- image
- image
- mask
What this is for
You cut a subject out, and now there's a thin bright line around it. Maybe the outline of the old background, glowing through the semi-transparent pixels at the edge - the classic "fringe". Everyone who has composited anything knows the fix: choke the matte in a little, soft edge back, done. That's all Image Alpha Edge does. Shrink or grow the alpha boundary, feather it, and hand you back an RGBA image plus the alpha as a mask.
The reason you want a dedicated node instead of "erode the mask and blur it" is what happens to hair. Background removal is the most commoditized operation in the ecosystem right now and still unsolved at the edges - as the KB puts it, the frontier moved years ago from "can it find the subject" to "can it survive hair, fur and semi-transparency", and nobody has won that. A hard binary erode on a wispy matte turns wispy hair into a staircase. This node doesn't do that.
How it works
Two mechanisms, and the first one is the interesting bit.
edge is signed: negative shrinks inward, positive expands outward, up to 256px either way. Under the hood that's a grayscale min/max filter (an erode or dilate) run directly on the alpha without binarizing it first. For a locally linear soft edge - which is what a segmentation matte gives you, a 1–3px ramp - a disk-shaped min filter of radius r is exactly a shift of that ramp by r pixels. Every alpha level set moves by r, the anti-aliasing survives, and a soft matte stays soft instead of collapsing to a 1px step edge. Hard mattes are unaffected: a 0/1 alpha erodes the same either way.
feather is a Gaussian blur sigma applied to the alpha after the edge move. Pipeline order is fixed: edge → feather → colour extension.
That last step is why this beats an erode-plus-blur. Both operations touch the alpha channel only; the subject's RGB is never blurred, dilated or recoloured. Pixels that were fully transparent and became visible get filled by a normalized convolution of the nearby covered pixels - a smooth colour field, not nearest-neighbour patches. It runs only when feather > 0, and reads from the post-edge alpha, so a fringe you just cut away can't be sampled back into the new band.
The inputs that matter
image - single or batch. If it has 4+ channels the alpha is used; RGB or greyscale input is treated as fully opaque (you'll get a fully white mask out, which is a quiet way to do nothing useful).
edge - default 0, −256 to 256. The only one you really tune.
feather - default 0, 0 to 256, step 0.1. Gaussian sigma on the alpha.
Two outputs: image (RGBA, alpha processed) and mask (the processed alpha, for mask-side nodes). Batch size is preserved across both.
Practical starting points: defringe after background removal with edge around −2 to −5 and feather 1–3. Weak halo on an already-soft matte, just edge = -1. If you're feathering, keep the shrink at roughly twice the feather so the soft band stays inside the original silhouette - otherwise your subject grows and eats into the background. With edge = 0 and feather = 0 the input comes back unchanged, pixel for pixel, which makes it safe to leave parked in a graph.
Install
It ships inside ComfyUI 1hewNodes - a large grab-bag pack (image, mask, resize, color, batch, IO, text and logic groups) that has its own bilingual node docs bundled in the repo and shown in the UI. Search the pack title in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
pip install -r ComfyUI-1hewNodes/requirements.txt
Restart ComfyUI afterwards. The requirements file is not small - opencv, scikit-image, rembg, transparent-background, ultralytics, psd-tools, av, torchaudio - because it covers the whole pack, not this node. You don't need any model downloads for Image Alpha Edge; it's pure OpenCV.
Common issues
Nothing happens on an RGB image. No alpha channel means "fully opaque", so edge has no boundary to move and the mask output comes back all white. Insert it after whatever produced the alpha - a remove-background node, Image Alpha Split, a matte pipeline.
A hard matte stays hard. The grayscale trick preserves existing anti-aliasing; it doesn't invent any. If your cutout is a jagged 0/1 mask, add feather.
This is not hole filling. It moves alpha level sets and never repairs interior holes. Fill holes first with something like the pack's Mask Fill Hole, then feed the result here.
Colours in the feathered band are rewritten. The colour extension overwrites RGB only for newly visible pixels, and it's on by default whenever you feather. If you needed the exact RGB sitting in your original transparent pixels, do your compositing against the node's mask output instead of its image.
The pack is built on ComfyUI's newer V3 node schema, so on a stale install nothing registers - update ComfyUI first. And there's almost no community chatter about this pack at all, so the in-repo docs are your real manual.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image, single or batch; uses the alpha channel when present (>=4 channels), otherwise treats the image as fully opaque | |
| edge | INT | 0-256–256 | Signed edge adjustment in pixels: negative shrinks the opaque region inward, positive expands it outward. Runs as grayscale min/max filtering on the alpha, so the matte's anti-aliasing is preserved |
| feather | FLOAT | 0.00–256 | Gaussian blur sigma applied to the alpha after the edge adjustment; 0 disables it |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |