Nodes/opencv-comfyui/OpenCV divide_3
ComfyUI Node

OpenCV divide_3

The twin of the scalar division node

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV divide_3
  • src2
  • dst
  • nparray
scale
dtype

divide_3 is the identical twin of divide_2: both call cv2.divide(scale, src2, dtype) and compute scale / src2 per pixel. The suffix is just the opencv-comfyui generator emitting one node per OpenCV overload declaration (MatLike and UMat), and both collapse to the same thing here. Pick whichever the search box hands you - there is no behavioral difference to hunt for.

The real content is on the divide_2 page. The one-liner: this is scalar division, the per-pixel inversion tool. Give it a constant scale and an image, and every pixel becomes scale / src2. That's how you invert a mask or a light map (255/x turns a 0–255 map into its byte-level inverse), build a compensation field, or normalize against a scalar. It's the mathematical opposite of multiply-by-constant, it's deterministic, and it's exactly the kind of $0 millisecond operation the KB's post-processing layer wants you using instead of reaching for a model.

Inputs: scale (FLOAT, the numerator constant), src2 (NPARRAY, the image being divided into), dtype (INT, -1 = match input type). Skip the optional dst out-parameter. Output: one nparray.

The divide family, so you can keep the four nodes straight: divide_0/divide_1 are image-over-image (src1 × scale / src2), and divide_2/divide_3 are scalar-over-image (scale / src2). Same operation family, two different jobs. If you want to divide an image by a constant, that's the image-over-image family with src2 as the constant - wait, no: the image-over-image overload still wants two images. For a true constant divisor you're in the right family here.

The one genuine gotcha, same as the rest of the divide family: zeros. Wherever src2 is 0, you're dividing by zero and OpenCV's type-dependent behavior gets ugly (inf/NaN in float images). If your input has real zeros and you're doing math on the output, threshold or add a tiny epsilon upstream.

Pack-wide plumbing: NPARRAY in and out - Image2Nparray before, Nparrays2Image after, batch_size==1 only.

Install: part of geroldmeisinger/opencv-comfyui - ComfyUI Manager → search "OpenCV", or:

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

restart, with opencv-contrib-python installed. The pack's classic failure - Cannot import name 'guidedFilter' from 'cv2.ximgproc' - means conflicting OpenCV wheels and blocks the whole pack until resolved.

Decision fatigue over divide_2 vs divide_3? Don't. They're the same node.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
scaleFLOAT
src2NPARRAY
dtypeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY