Nodes/comfyui_private_postprocessor/Private ImageCPostprocessor
ComfyUI Node

Private ImageCPostprocessor

Healing the holes your background remover left behind

By githubYiheng·Created 2 years ago·Updated 2 years ago· 1
Private ImageCPostprocessor
  • image
  • image
  • success
kernel_size3

You know the moment after a good background removal: the subject is cut out beautifully, and then you zoom in and it's dotted with tiny transparent specks and hollows - pinholes in the hair, a see-through gap in an arm, flecks of semi-transparent noise on an edge. ComfyUI will happily hand you an RGBA cutout and then stand there while you try to fix those by hand. ImageCPostprocessor is the small, blunt tool someone wrote for exactly that job: it fills the transparent holes inside an opaque cutout and hands you back a clean image.

It lives in the pack comfyui_private_postprocessor, a tiny two-node toolbox from mid-2024 with an empty README and roughly zero community footprint. Don't let the obscurity worry you - this node is simple, has no model files, no API, and needs nothing beyond what ships with ComfyUI. It's just rough around the edges, and we'll get to that.

How it works

Feed it an RGBA image - the transparent PNG your background-removal or matting node outputs. The node reads the alpha channel, thresholds it into a hard binary mask (anything with alpha above 1 counts as "opaque"), and runs OpenCV's contour finder over it. The trick is that it's looking for holes: transparent regions fully surrounded by opaque pixels, which appear as contours with a negative oriented area.

Then it treats holes differently by size:

  • Small holes (under about 80 pixels of area) are pinhole specks. It fills them solid with the region's median color, which blends in far better than a mean would on noisy edges.
  • Bigger holes are hollows you want to close, not paint over. It fills them by dilating the surrounding opaque pixels inward - the kernel_size controls how far that dilation reaches.

Finally it stamps the alpha channel back to the clean binary mask, so what was translucent garbage becomes either solid or fully transparent. The result: a cutout where the interior is watertight.

The inputs that matter

Only two, and one of them is basically a tuning knob:

  • image (IMAGE) - your RGBA cutout. This is the whole job: nothing gets generated, no model involved.
  • kernel_size (INT, default 3) - the dilation kernel for the big-hole fill. Keep it small for pinhole cleanup; nudge it up (5–7) when you're closing larger hollows. Too big and it starts eating real detail around edges.

Outputs: image (IMAGE) - the cleaned cutout, ready to composite over anything - and success (BOOLEAN), which is False when no holes were found, so you can tell "nothing to do" from "something went wrong."

Install

ComfyUI Manager → search comfyui_private_postprocessor, or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/githubYiheng/comfyui_private_postprocessor

Then restart ComfyUI. That's it - the code only imports numpy, PIL, torch and cv2, all of which ComfyUI already has, so there's no requirements install and no model download.

Where people get burned

  • Feed it a plain RGB image and it dies. The code flat-out checks for an alpha channel, prints "Provided image does not contain an alpha channel." and then trips over its own error handling. It only makes sense downstream of a background-removal or matting node that outputs RGBA.
  • The contour logic assumes a transparent border around your subject. That's the normal cutout case, but if your opaque subject touches the image edges, the hole-finding math gets confused.
  • No holes, no glory. If your cutout is already clean, success comes back False and the image passes through unchanged - don't mistake that for a failure.

It's unmaintained since 2024 and the error handling shows its age, but for a two-second pass over a speckled cutout it does real work with zero dependencies.

CategoryTools

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
kernel_sizeINT3

Outputs (2)

NameTypeDescription
imageIMAGE
successBOOLEAN