Nodes/Akatz Custom Nodes/Normalize Image Color | Akatz
ComfyUI Node

Normalize Image Color | Akatz

Hard black-and-white, in whatever color you want

By akatz-ai·Created 2 years ago·Updated 9 months ago· 32
Normalize Image Color | Akatz
  • image
  • IMAGE
threshold0.200
red255
green255
blue255

The display name - "Normalize Image Color" - undersells it. What this node actually does is flatten an image batch into hard black-and-white: every pixel bright enough to count as "not black" gets set to one solid color (white by default), and everything near black becomes pure black. It's a mask cleaner, a binarizer, and a recolor tool all in one, and the fact that it works on whole batches (including video frame stacks) is why people keep it around.

Why you'd reach for it

Masks that come out of segmentation, depth-to-mask conversions, and various estimators are rarely clean black-and-white. You get gray halos, anti-aliased edges, noise in the background. If you feed that gray mush into a compositing step, an inpainting mask, or anything that keys on "is this pixel in or out," you get soft, wrong results. This node decides, per pixel, on or off - and because it lets you pick the output color, it doubles as a mask-recolor node for workflows that key on specific RGB values rather than on alpha.

How it works

Straightforward math, and the docstring's own description is "sets the non-black pixels of input images to one specified color." For each pixel it computes brightness as the mean of the RGB channels. If that mean is below threshold, the pixel becomes black; otherwise it becomes your chosen red/green/blue. The tensor is clamped to [0,1] first, so out-of-range inputs can't surprise you, and it operates frame-by-frame, so it handles a (num_frames, H, W, C) batch exactly like a single image.

The inputs that matter

  • image (IMAGE) - the input batch or video tensor.
  • threshold (FLOAT, default 0.2) - the brightness cutoff between "black" and "not black". Raise it if you want to catch more dim pixels; lower it if faint background noise keeps surviving.
  • red / green / blue (INT, default 255 each) - the color assigned to non-black pixels. Defaults to pure white, which is the classic mask look.

Output is a single IMAGE with the same shape as the input.

Installing the pack

It lives in Akatz Custom Nodes (akatz-ai/ComfyUI-AKatz-Nodes). Install via ComfyUI Manager by searching "Akatz", or:

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-AKatz-Nodes

Restart ComfyUI and it appears under 💜Akatz Nodes. Dependencies are numpy, torch, opencv-python, and pydub per the pack's requirements.txt; numpy and torch already ship with ComfyUI, and the other two only matter for the pack's image/audio nodes - nothing extra to install for this one, and no models to download. The README defers real docs to the author's Notion page and a custom GPT.

Gotchas

  • "Black" is decided by mean-channel brightness, so a dark but saturated color (deep red, navy) can read as black and get zeroed. If your input isn't near-gray, bump the threshold or pre-binarize.
  • It's RGB-only; alpha channels are ignored. Don't use it to fix transparency.
  • Slightly confusingly, the class that runs this node is registered as AK_NormalizeMaskImage in the pack while showing up in the menu as "Normalize Image Color | Akatz". When a workflow you load complains about a missing node, it'll usually name the class - that's this node, so the pack is what's missing.
Category💜Akatz Nodes/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
thresholdFLOAT0.2000–1
redINT2550–255
greenINT2550–255
blueINT2550–255

Outputs (1)

NameTypeDescription
IMAGEIMAGE