๐ผ> Get Mean Color
Read the average color out of an image or a masked region
- image
- mask_opt
- int
- red
- green
- blue
- hex
The counterpart to this pack's RGB Color node: where that one lets you dial in a color by hand, Get Mean Color reads one back out of an actual image. Point it at a region and it tells you, numerically, what color that region averages to.
How it works
Fed a plain image with no mask, it averages every pixel in the frame - which, on anything busy or detailed, tends to land somewhere near a boring mid-gray, because that's what averaging a whole scene usually does. The useful case is with mask_opt connected: mask off just the sky, just a piece of clothing, just a subject's skin, and the average color that comes back actually means something. This pack's own Light Source Mask is a natural feed for it - grab the bright regions of an image, then read their average color, if you want to know roughly what color light is dominating a scene.
There's also an amplify toggle with no further description in the node's own schema, so the honest answer is: flip it and compare. Expect it to push the sampled color further from a washed-out average rather than reading it as-is - but confirm on your own image before relying on it for anything precise.
The inputs and outputs that matter
image(IMAGE) - required.amplify(BOOLEAN, default false) - see above; test it on your own image.mask_opt(MASK, optional) - restricts the sampled area; leave it out to average the whole image.int(INT) - the packed color value, same format as RGB Color's output.red,green,blue(INT each) - the individual channel values.hex(STRING) - the color as a hex string, useful anywhere downstream that wants text instead of a packed int.
That's five outputs from one read - pick whichever format the next node in your graph actually wants.
How to install it
Via ComfyUI Manager: search "yanc" or "ComfyUI_yanc" and install, then restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ALatentPlace/ComfyUI_yanc
then restart ComfyUI. No extra dependencies or model downloads.
Common issues & troubleshooting
The result is a boring, muddy gray. That's what you get averaging an entire unmasked scene - it's not a bug, it's what averaging does. If you want a meaningful color, mask down to a specific region first.
Mask and image resolution mismatch. The usual ComfyUI trap: mask_opt needs to match the image's dimensions, or you'll hit a shape error.
You need a hex string somewhere and only have RGB Color's int. Use this node instead - it's the one in the pack that actually gives you a hex output, RGB Color doesn't.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | โ | |
| amplify | BOOLEAN | false | โ |
| mask_optopt | MASK | โ |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| int | INT | โ |
| red | INT | โ |
| green | INT | โ |
| blue | INT | โ |
| hex | STRING | โ |