CV Reshape Array
The boring node that four other nodes won't work without
- nparray
- nparray
It's numpy.reshape with a widget. No math, no pixel processing, no cleverness. And yet it's the node that makes classifier predictions paintable, arithmetic on colour rows possible, and geometry output displayable. If you're working in the data half of this pack, you'll use it constantly.
What it does
nparray in, same values out in a new shape. rows and cols set the target shape, and 0 means infer - at most one of them may be 0, because numpy needs to know how many elements the array has. channels is optional and appends a third axis: 2 for point pairs, 3 for colour, whatever your data is.
It reinterprets, it never interleaves. The values appear in the same order they came in, so a reshape that looks right but is actually a transpose will give you a scrambled image. If you need to actually move axes, that's CV Permute Axes.
And when the element count doesn't fit - rows * cols * channels ≠ the number of elements - it raises. That's a wiring mistake, not bad data, and loud failure is the right call here: a silent truncation would poison everything downstream in a way you'd only notice two nodes later.
The uses, in order of how often they come up
Making predictions visible. This is the headline one. CV Coordinate Grid produces a dense meshgrid of sample positions; CV Train Classifier classifies every position; the query result is a flat (N,) vector alongside rows and cols describing the grid. Reshape the predictions to (rows, cols) and you have a label image - a picture of the classifier's decision regions. Throw it through CV Color Map and you've rendered the classic ML decision-boundary figure, computed entirely in-graph with no dataset and no downloads. That's workflows/80_ml_decision_boundary.json.
Making (3,) rows arithmetic-compatible. A single colour or point comes out of some nodes as a (3,) row, and the raw cv2_* wrappers want a genuine 2-D Mat before they'll do arithmetic on it. The pack's own docs call this out as a required step rather than a nicety - reshape to (1, 3) and the wrapper stops complaining.
Pulling channels apart and back together. CV Concat Arrays joins things along an axis, CV Slice Array takes a range out of one axis, this reshapes the result. Between them you can reorder channels, split an RGBA into RGB+A, or flatten a batch for a stats pass and put it back.
Reshaping for a specific consumer. Fourier outputs (workflows/19_fourier_playground.json), matrix decompositions (56_matrix_decomposition.json), QR encode/decode (82_qr_encode_decode.json), PnP solvers (55_pnp_solvers.json) - every module that emits a flat buffer needs this to hand it back as an image or a matrix. It shows up in more of the pack's example workflows than almost any other utility node, which is the honest measure of a plumbing node.
Install
Ships in ComfyUI CV (bmad4ever/comfyui_cv), GPL-3.0 fork of opencv-comfyui:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
# restart ComfyUI
Manager: search the pack title. Python ≥ 3.12 and a V3-node-API ComfyUI build - a pack like this one, rewritten on the V3 API, won't register any nodes on an older frontend.
Working without a preview
The frustrating part of a reshape bug is that you usually can't see the array. Pair this with the pack's inspection nodes: CV Array Shape and CV Inspect CV Data give you shape and dtype as actual outputs you can wire, and Preview CV Array renders a raw ndarray as an image so you can look at it. Between those three you can find a reshape bug in a minute instead of an hour.
The pack tags this node TB (type bridge) - pure IO, no image processing - and that's the correct way to think about it. It's not doing anything you couldn't do in a Python node; the value is that it's a Python node you don't have to write, inside the same NPARRAY socket type as everything around it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| nparray | NPARRAY | Array to reshape; the element count must match rows * cols (* channels). | |
| rows | INT | 00–2147483647 | Target row count (height). 0 = infer from the element count and the other dimensions. |
| cols | INT | 00–2147483647 | Target column count (width). 0 = infer. |
| channelsopt | INT | 00–512 | Optional third axis size (e.g. 2 for point pairs, 3 for color). 0 = no channel axis. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | The same values in the new shape. |