Nodes/opencv-comfyui/OpenCV transpose_0
ComfyUI Node

OpenCV transpose_0

The node that flips your array on its diagonal

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV transpose_0
  • src
  • dst
  • nparray

cv2.transpose mirrors a matrix across its main diagonal - rows become columns. As a ComfyUI node, transpose_0 is a tiny, honest utility: one image array in, one transposed array out. It's not a rotation and it's not a flip; it's the linear-algebra transpose, which on a 2D image means the top-left stays put and everything else slides across the diagonal. Photo editors rarely offer this as a one-click filter because nobody wants it for photographs. But as a geometry operation for arrays, it's occasionally exactly what a workflow needs.

When would you actually use it? If you're treating images as matrices - doing math pipelines, feeding SVDecomp or other linear-algebra nodes in this pack - the transpose is the operation that turns a row-vector layout into a column-vector layout, which is precisely the kind of shape mismatch that produces silent nonsense downstream. In the pack's auto-generated "all of cv2, expect dragons" world, this node is the plumbing that keeps matrix-shaped things shaped right.

Inputs and outputs that matter

  • src (NPARRAY) - the array to transpose. For a color image, OpenCV transposes the first two dimensions (height/width) and leaves channels alone.

Optional dst is the call-by-reference out-parameter, exposed as an input - leave it unwired. The output is one nparray. If you wanted a 90° rotation instead, note the difference: a true rotation would reorder the channel axis too (that's cv2.rotate with a rotation-code), while transpose just mirrors the H×W plane. Swap the two and the diagonal-mirrored result is usually not what you meant.

Installation

One pack for everything: ComfyUI Manager (search "OpenCV" or geroldmeisinger/opencv-comfyui), or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Dependency is opencv-contrib-python (pip install opencv-contrib-python). No models, no downloads.

Common issues

This node is about as error-free as this pack gets - no composite literals, no grayscale requirement. The two things to watch are the pack-wide ones: Image2Nparray only accepts batch size 1 (split with ImageFromBatch if needed), and the output must go through Nparrays2Image to become an IMAGE again. Oh, and the diagonal mirror is easy to mistake for a rotation; if your image came back "wrong," check that it wasn't the transpose doing exactly what you asked it to do.

Categoryimage/OpenCV

Inputs (2)

NameTypeDefaultDescription
srcNPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY