Get Average Color From Image Jannchie
Pull one RGB value out of a whole image
- image
- mask
- red
- green
- blue
This one has nothing to do with the Diffusers pipeline that makes up most of this pack - it's a small standalone utility that happens to ship in the same node collection. What it does is exactly what the name says: hand it an image, get back a single color as three numbers.
What it is and how it works
Two different ways to compute "the color of an image," and the choice between them genuinely changes the answer. Mean takes the arithmetic average of every pixel's red, green, and blue values across the image (or just the masked region, if you supply one). That's mathematically clean, but it can hand you a color that doesn't actually appear anywhere in the source - average a photo that's half pure black and half pure white and mean gives you flat mid-gray, a color the image never contains a single pixel of. Mode instead picks the single most common pixel value in the image - an actual color that's really there, just the one that shows up most. For something like sampling a subject's skin tone or a dominant background color, mode is usually the more intuitive choice; for a general sense of an image's overall brightness or tint, mean is the more standard one.
The optional mask lets you restrict the sample to a specific region - useful if you want the average or dominant color of just a face, just a background, or just whatever you've painted a mask over, rather than the whole frame diluting the result.
The inputs and outputs that matter
image(required) - the image to sample.average(required, enum:mean/mode) - which computation to run. This is the one real decision this node asks you to make.mask(optional) - restrict sampling to a masked region instead of the whole image.
Outputs are three separate floats: red, green, blue - not a single combined color value, but three wires you can feed individually into anything downstream that takes RGB components separately. The most obvious pairing in this same pack is Get Filled Color Image, whose red/green/blue inputs line up exactly with what this node outputs - sample a color here, paint a solid block with it there.
Installing it
Part of the ComfyUI-J pack. ComfyUI Manager: search ComfyUI-J, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/Jannchie/ComfyUI-J
cd ComfyUI-J
pip install -r requirements.txt
Because this node doesn't touch Diffusers, Compel, or any model weights at all, it doesn't add to the dependency-conflict risk the rest of this pack carries - it should just work once the pack itself is installed, no extra downloads.
Where people get burned
The mask input wants a MASK, not an IMAGE - a common mixup across ComfyUI generally, not specific to this node, but worth double-checking if the node errors on connection rather than assuming something's broken. If you're trying to feed it a black-and-white image as a mask instead of an actual mask output from a masking node, that's usually the fix.
The other thing to keep in mind is that mean and mode can disagree sharply on a busy, high-contrast image, and neither one is "wrong" - they're answering different questions. If the color this node hands you looks nothing like what you expected, try switching the average setting before assuming the node's misbehaving; on a subject against a strongly contrasting background, the two modes can land on genuinely different colors.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| average | COMBO | 2 options: mean, mode | |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| red | FLOAT | — |
| green | FLOAT | — |
| blue | FLOAT | — |