ComfyUI Node

White Percentage

The One-Input Node That Tells You How White Your Image Is

By alexpuliatti·Created 2 years ago·Updated 2 years ago· 0
White Percentage
  • image
  • percentage

WhitePercentage is about as minimal as a ComfyUI custom node gets: feed it an image, and it hands you back exactly one float - the percentage of that image that's white. The pack's README doesn't bother with more than a sentence of explanation ("a simple white extractor node for comfyui"), and the whole pack is this single node. Don't let the size fool you into scrolling past it. It's a genuinely useful little QC gate.

Why would you reach for it? The most common reason is blank-output detection. When a generation goes wrong - a model coughing up a white frame, img2img at too high a denoise, a video pass that renders nothing - it tends to fail white rather than fail loud. One WhitePercentage node feeding a comparison gives you "if the output is 99% white, rerun it," which is the closest thing to a guardrail ComfyUI has without extra plumbing. Second use case: you've got a product shot on a white background and want to confirm that background is actually clean before you hand it to a background-removal or upscaler pass. Same idea, different workflow.

The mechanism is easy to trust because there's so little of it. ComfyUI hands the node a float tensor in the 0–1 range; the node scales it by 255 to bytes, converts to grayscale (RGB and RGBA are both handled), binarizes with a threshold of 254, counts white pixels, divides by the total, multiplies by 100, and rounds to two decimals. So "white" here means a grayscale value of 254 or 255 - not "visually white." That's the one detail to remember.

The full interface is: one input, image (IMAGE), and one output, percentage (FLOAT). That's it. No settings to fumble, no hidden model.

Three gotchas, in order of how often they bite:

  • It only looks at the first frame. The code reads image[0], so feed it a batch of eight and you get the percentage of frame one, silently. If you're scoring a batch, loop frames yourself.
  • The 254 threshold is strict. A slightly off-white background - #FAFAFA, a warm white, a vignette shadow - reads as not white. Don't be shocked when an image that looks white to you scores 60%.
  • Alpha is ignored. RGBA images get grayscaled from their RGB channels, so a transparent-but-white pixel still counts as white. If you care about transparency, this isn't the tool.

For the output to earn its keep, wire the float into a comparison node - rgthree's Power Puter, WAS Node Suite's Number Compare, whichever you already have - and use the resulting boolean to gate a rerun or flip a switch. The node has no other output, so if you're not branching on the number, you don't need the node.

Install is painless. ComfyUI Manager → "Install Custom Nodes" → search comfyui-white-extractor, or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/duchamps0305/comfyui-white-extractor

Then restart ComfyUI. There are no model downloads, no API key, no weights. Dependencies are just opencv-python and numpy - both almost certainly already sitting in your ComfyUI environment (ComfyUI itself ships numpy), so on most setups it installs clean with zero downloads. If you do hit an import error for cv2, pip install opencv-python into ComfyUI's Python env and restart.

Bottom line: it's a twenty-line node you could write yourself in five minutes, which is exactly why you can trust it. Not a crowd pleaser, not a fixer-upper - a small honest utility that does one thing and does it deterministically.

CategoryImage Analysis

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
percentageFLOAT