Nodes/opencv-comfyui/OpenCV invert_1
ComfyUI Node

OpenCV invert_1

The same matrix inverse, minus the confusion

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV invert_1
  • src
  • dst
  • float
  • nparray
flags

By now the pattern writes itself: OpenCV invert_1 is the duplicate overload of OpenCV invert_0. cv2.invert shows up twice in OpenCV's type stubs, the generator made two numbered nodes, and they're interchangeable. But there's one piece of context I want to hit again, because it's the thing that makes both of these nodes dangerous: invert means matrix inverse, not color inversion. If you want a photo negative, bitwise_not_0 (same pack) is the node. invert_1 will hand you a matrix and a float, and it will not make your image look like film.

What it does

Computes the inverse of a square matrix using the decomposition in flags:

  • 0 DECOMP_LU - fast, fails on singular input.
  • 1 DECOMP_SVD - robust, copes with degenerate matrices.
  • 24 (EIG / CHOLESKY / QR) - special cases.
  • 16 DECOMP_NORMAL - OR into the above for least-squares solving.

Returns the inverted matrix plus a float whose meaning depends on the flag (determinant for LU, condition ratio for SVD) - your singularity check.

Inputs and outputs

  • src - NPARRAY, square float matrix.
  • flags - INT, decomposition (0 is the sensible default).
  • dst - optional out-parameter, returned on the output.
  • Outputs: float and nparray (the inverse).

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
cd opencv-comfyui
pip install -r requirements.txt

or ComfyUI Manager → "opencv-comfyui". No model downloads; requirements.txt is opencv-contrib-python, numpy, torch.

Gotchas

The _1 suffix really is nothing special - it's not the SVD "advanced" variant and it's not newer; both nodes call the same cv2.invert with the same flags. Feed it a square float matrix, watch the float output for near-zero (singular = no valid inverse), keep batch_size == 1, and reach for bitwise_not_0 whenever you catch yourself wanting inverted colors instead.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
flagsINT
dstoptNPARRAY

Outputs (2)

NameTypeDescription
floatFLOAT
nparrayNPARRAY