Nodes/opencv-comfyui/OpenCV max_1
ComfyUI Node

OpenCV max_1

The identical twin of OpenCV's brighter-pixel node

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

Quick truth so you don't waste a half hour hunting for the difference: there isn't one. max_1 and max_0 are the same node - same cv2.max function, same inputs, same output, same behavior. The opencv-comfyui pack auto-generates a node for every overload it finds in OpenCV's type definitions, and cv2.max is declared twice, so you get two. Which means the only decision you need to make is "which one looks nicer on my canvas."

What the node does is blessedly simple: take two arrays, and at every pixel keep the larger value. It's element-wise maximum, no more, no less. That makes it one of the handiest little compositing primitives in the pack:

  • Merge two masks. Face mask + garment mask, feed both into max_1, get a combined mask that's set wherever either one is. Classic "inpaint all of it at once" move.
  • Union soft masks. Because it works on values, not just 0/1, feathered and anti-aliased masks merge without hard edges.
  • Bright-pass compositing. Max a glow/bloom pass back over the original and only the bright pixels win through.

Inputs and outputs

  • src1, src2 - two NPARRAYs (raw numpy arrays, BGR uint8 by default). Same dimensions or OpenCV will throw an assertion.
  • dst - optional, and skip it. It's an out-parameter in the underlying C++ function; the pack exposes it as an input but the README's rule is "avoid the optional out-parameters."
  • nparray output - the element-wise max, ready for the next node or Nparrays2Image to get back to a normal ComfyUI image.

Setup and the usual suspects

Install via ComfyUI Manager (search "opencv-comfyui") or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

then restart ComfyUI. The pack needs opencv-contrib-python, numpy, and torch. If OpenCV's already in your environment from another custom node, this just works - the main thing that breaks people is conflicting OpenCV versions (Cannot import name 'guidedFilter' from 'cv2.ximgproc' is the tell).

Remember the plumbing: ComfyUI images are RGB float tensors in 0..1; OpenCV works on BGR uint8 0..255 nparrays. So it's Image2Nparray → max_1 → Nparrays2Image, and Image2Nparray only accepts batch_size==1 - slice your batch if it complains.

And one more time for the back row: max_1 merges two arrays. It's not a clamp, it's not a threshold - it's "the brighter pixel wins," and now that you know that, go union some masks.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
src1NPARRAY
src2NPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY