Get All Alpha Layers JNK
Pull every significant cutout out of a mask
- image
- mask
- rgb
- mask
- rgba
Get All Alpha Layers is the "keep everything" half of the JNK pack's alpha-extraction pair. Feed it an image and a mask, and it turns every significant connected region of that mask into a clean cutout: you get the subject(s) on a white background, a tidy mask, and an RGBA version with the alpha baked in. The sibling node, Get One Alpha Layer, keeps only the largest region; this one keeps all of them, down to a size threshold - which is what you want when an image genuinely contains multiple objects and you don't want the small stuff silently dropped.
Think of it as a cleanup pass between a rough mask (from a segmentation node, a manual paint-in, a color-pick) and the composite where you actually use the cutouts. The connected-region logic also makes it a noise filter: specks and stray pixels in your mask get discarded if they fall below the area threshold, leaving you with only the blobs that matter.
How it works
The mechanism is computer vision, not machine learning. The node runs cv2.connectedComponentsWithStats on your mask (binarized at a 0.1 threshold), finds every connected blob, and keeps any whose area is at least 1% of the largest region's area. Everything below that is treated as noise and dropped. The surviving regions are merged into one output mask; the RGB output composites the image's pixels onto white using that mask, and the RGBA output carries the mask as its alpha channel.
Inputs and outputs
image- the IMAGE whose pixels you want to keep.mask- the MASK defining what's foreground.
Outputs, all three:
rgb- cutout on a white background.mask- the cleaned-up mask (noise regions removed).rgba- cutout with alpha, ready for Add Layer Overlay or a compositor.
It handles batches too: if your mask batch has one entry but your image batch has many, that single mask is applied to every image; with matching batch sizes, they're paired up.
Installing it
Pack install: search JNK in ComfyUI Manager, or
cd ComfyUI/custom_nodes/
git clone https://github.com/Aljnk/ComfyUI-JNK-Tiny-Nodes.git
This one does need opencv-python - the first entry in the pack's requirements.txt - so if Manager didn't install dependencies for you, run pip install opencv-python and restart.
Where people get burned
Two things. First, the node writes a debug_regions.png file into ComfyUI's working directory every time it runs - a colored visualization of the regions it found. Harmless, but if a mystery PNG starts appearing in your install folder, that's where it's from. Second, the threshold behavior: if your mask has no region above the 1% floor, you get a white RGB, an all-zero mask, and an empty RGBA - not an error, just nothing useful. If that happens with a small object, your mask's largest blob is too small relative to the canvas; the "all" in the name doesn't mean "every pixel," it means "every region that clears the bar."
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| mask | MASK | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| rgb | IMAGE | β |
| mask | MASK | β |
| rgba | IMAGE | β |