Nodes/opencv-comfyui/OpenCV scaleAdd_0
ComfyUI Node

OpenCV scaleAdd_0

The two-image blend you'll actually use

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV scaleAdd_0
  • src1
  • src2
  • dst
  • nparray
alpha

scaleAdd_0 is one of the few genuinely everyday nodes in this pack, because it's just dst = src1 * alpha + src2 - scale the first image by a factor, add the second, done. It wraps cv2.scaleAdd, and while it sounds like arithmetic, what you'll actually use it for is blending: fade between two images, lay one over another with a weight, or superimpose content at partial opacity.

What you can do with it

Concretely: alpha = 1 gives you a straight sum of both images (which will clip on bright content). alpha = 0.5 gives you a 50/50 crossfade of src1 and src2 - exactly the "dissolve between A and B" move that post-processing folks reach for constantly. Negative alpha subtracts. And because src2 is added on top of the scaled result, you can use it to push an offset - add a constant image, a watermark, or a precomputed adjustment layer back into the frame.

It's a sibling of addWeighted (which adds a gamma term and is the other famous blend), but this one is simpler, which is honestly why you'd pick it: fewer knobs, fewer ways to misread the output. In the KB's post-processing framing, this is a stable, deterministic color-and-compositing primitive - nothing to tune except the one number that matters.

Inputs and outputs

Inputs: src1 (NPARRAY), alpha (FLOAT), and src2 (NPARRAY), all required, plus an optional dst out-parameter you should leave unwired per the pack README. Output is a single nparray - same shape and channel count as the inputs, so make sure src1 and src2 match before you wire them, or OpenCV throws a size/type assertion. Both inputs need the same number of channels; you can't cleanly blend a grayscale with a BGR image in one call.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Install: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python for the dependency (no model downloads). And the usual pack plumbing applies: Image2Nparray in, Nparrays2Image out, cvtColor where channel order matters - Comfy lives in RGB, OpenCV in BGR.

Troubleshooting

Where people get burned: feeding it a batch larger than one (only batch_size==1 is supported on the way in) and forgetting that alpha is a plain number you type in the widget - there's no dropdown, and the node won't warn you if the blend clips. Also remember the _0/_1 split is just the MatLike/UMat overload duplication; both behave identically. If your job is a quick crossfade or overlay, this is the node I'd reach for over its more famous cousin.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
src1NPARRAY
alphaFLOAT
src2NPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY