合并颜色
Merge three grayscale channel images back into a color image
- R
- G
- B
- image
Sometimes you need to break an image into its red, green, and blue channels, mess with them individually, and put them back together. That last step - the putting-back-together - is this node's whole job. It takes three IMAGE inputs (R, G, B), pulls the first channel out of each, and concatenates them into a single RGB image. It's the inverse of the pack's "分离颜色" (Separate Color) node, and the two are designed as a pair: split, transform one channel, recombine.
The mechanism is simple and worth understanding because it explains the input requirements. Each input is expected to be a grayscale-ish image where the first channel holds the data you care about (the source node's docstring describes them as "channel brightness grayscale images"). extract_channel takes img[:, :, :, 0:1] - the first channel of each input - and then the three get concatenated along the channel axis, with an alpha channel of 1.0 appended. So you don't need actual single-channel tensors; a normal RGB image in, and only its red channel is used as the "R" of the output. Output: one image (IMAGE), shape (batch, H, W, 3).
Why would you do channel surgery at all? The classic ComfyUI reasons: swapping or mixing channels to create effects (e.g., putting the luminance of one image into the green channel of another), generating channel-based masks for masking-detection work, or debugging per-channel operations. If you've ever seen the KB's masking-detection docs on working with grayscale channels as masks, this is the tool that turns those single-channel ideas back into viewable color.
The one real constraint: all three inputs must share the same batch, height, and width. The node validates this explicitly - mismatch any of the three and it raises "所有颜色通道必须具有相同的尺寸" (all color channels must have identical dimensions), which is the standard ComfyUI channel-merge rule and the most common reason a run fails. Note there's no alpha input - alpha is always set to 1.0, so if you're round-tripping images that had transparency, the alpha comes back opaque.
Install: part of ComfyUI-My-Nodes - ComfyUI Manager → search "ComfyUI-My-Nodes", or git clone https://github.com/Tagbliton/ComfyUI-My-Nodes into custom_nodes and restart. Local utility, no API key, no network.
Gotchas. The dimension-matching rule is the big one - resize or crop all three to identical dimensions before merging. And the "first channel only" behavior is easy to forget: if you feed it three full-color images, you're actually feeding it their red, green, and blue channels, not the full images. That's usually what you want from a node named "Combine Color," but it surprises people who expect it to average or blend. Feed it the R/G/B outputs of the sibling "分离颜色" node and you're back to exactly what you started with.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| R | IMAGE | — | |
| G | IMAGE | — | |
| B | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |