OpenCV add_0
OpenCV add_0
- src1
- src2
- dst
- mask
- nparray
add_0 is plain pixel addition: dst = src1 + src2. Two images in, the per-pixel sum out. What makes it worth a node rather than a grab-bag arithmetic op is that it's saturating - anything that would overflow past 255 clamps at 255 instead of wrapping around to black. That single detail is the difference between "two images composited" and "two images XOR'd into a mess", and it's why cv2.add exists as its own function in the first place.
It's also the right tool for boosting brightness deterministically: add a copy of the image to itself and you've doubled the exposure, clipped cleanly. No model, no seed, instant. That's the whole spirit of this layer of the stack - the post-processing doc in this very KB makes the case that a $0 deterministic pixel op should beat burning a diffusion pass for work a lookup table does perfectly, and add_0 is that kind of node.
How it works
cv2.add(src1, src2[, dst[, mask[, dtype]]]). Both inputs should be the same size and type. The mask input restricts the addition to nonzero-mask pixels. The dtype input sets the output array type; -1 means "same as the inputs", and in most ComfyUI uses that's what you want - keep it -1 unless you specifically need a different output type and know why.
Note the difference from the accumulate family: add_0 saturates at the max of your type (255 for uint8) and expects uint8 images in the first place. The accumulators don't saturate and demand float inputs. Different jobs, and reaching for the wrong one is a classic mix-up.
The inputs that matter
- src1 / src2 (NPARRAY) - the images to add.
- dtype (INT, required) -
-1= same type as inputs; that's the sane default. - dst (NPARRAY, optional) - the out-parameter; skip it and read the return.
- mask (NPARRAY, optional) - add only where the mask is nonzero.
Output: one nparray - the saturated sum.
Where it sits
In a standard chain (IMAGE → Image2Nparray → add_0 → Nparrays2Image) it's mostly useful for exposure pushing, highlight compression experiments, or combining two aligned images where you want no wrap-around artifacts. For simply blending two images with control, addWeighted_0 is the better tool - it lets you weight each side before adding. add_0 is the blunt instrument; keep it for when the bluntness is the point.
Installing opencv-comfyui
ComfyUI Manager → search "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart ComfyUI. Dependency: opencv-contrib-python.
Gotchas
- Size mismatch - src1 and src2 must be the same dimensions, or OpenCV asserts.
- Batch_size == 1 - conversion nodes refuse batches; use
ImageFromBatch. - Saturation, not wrap - if you expected modular arithmetic, that's
bitwise_xor, notadd_0.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| src1 | NPARRAY | — | |
| src2 | NPARRAY | — | |
| dtype | INT | — | |
| dstopt | NPARRAY | — | |
| maskopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |