Nodes/ComfyUI CV/CV Identity Map
ComfyUI Node

CV Identity Map

The blank sheet every remap chain starts from

By bmad4ever·Created 4 months ago·Updated 16 days ago· 1
CV Identity Map
  • image
  • map_x
  • map_y

A remap is just a lookup table: for every output pixel, cv2.remap asks "which source coordinate should I sample?" Give it two arrays - map_x and map_y - and it does the rest. CV Identity Map generates the do-nothing version of those arrays: map_x[y][x] = x, map_y[y][x] = y. Nothing moves. Which is the point, because from there you can edit the coordinates instead of the image, and that's how this pack lets you stack five distortions for the price of one resample.

How the chain works

Feed it an image - it only reads the width and height, so your picture is never actually processed by this node - and you get two float32 HxW maps back, map_x and map_y. Every other node in the remap category rewrites those coordinates: radial lens, cylinder wrap, pinch/stretch, wave, displacement by another image's brightness, flow fields, polynomial radial - and CV Homography Map, which folds a perspective transform into the same chain.

Chain as many as you like. They compose in NPARRAY space, and the whole stack collapses into a single cv2_remap at the end via the low-level wrapper. That last part is the reason to prefer this to stacking warps: five separate warpAffine calls means five rounds of bilinear interpolation and five rounds of softness. One remap means one. If you've ever chained two or three geometric corrections and watched an image turn to mush, this is the fix.

Here's the honest trade: the remap-chain style is more abstract than dropping two warp nodes in series. You're wiring coordinate arrays, not pictures, and a broken chain produces output that looks like a misplaced picture rather than an error. Start with an identity map, add one distortion, and preview the result through the final remap before you add the second. Debugging four chained maps at once is nobody's idea of a good time.

Where it fits in a real workflow

The classic uses are the ones that keep coming up in correction work: barrel/pincushion from a wide lens, chromatic-aberration-style per-channel scaling, dewarping a projected surface, and the "warp a quad flat" move from the pack's own demo gifs. It's also the honest way to undo a lens distortion once and then compose a perspective change on top without a second resampling pass.

Anything downstream of the maps is the pack's usual NPARRAY world, and ComfyUI masking and compositing nodes don't speak that language, so the far end of a chain will be a cv2_remap and then a bridge node back into an IMAGE.

Install

ComfyUI Manager, search the pack title comfyui_cv (bmad4ever/comfyui_cv). Or:

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv

Restart after. This pack requires Python ≥ 3.12 and a recent ComfyUI on the V3 node API - every node is declared with io.ComfyNode/io.Schema and there are no NODE_CLASS_MAPPINGS dicts, so an old ComfyUI build simply won't load it. One dependency, and it has to be contrib:

pip install "opencv-contrib-python-headless~=5.0.0.93"

All four OpenCV distributions share the same site-packages/cv2. Install a non-contrib wheel on top of a contrib one and the contrib submodules are silently emptied - the contrib nodes disappear from the node menu with nothing in the log to explain it. The pack includes tools/repair_opencv_contrib.py with --check and --apply for that exact situation.

The traps

You ran a remap and got a blank or scrambled image. The usual cause is direction: a remap map is expressed in the destination's coordinate space, and it's easy to build one that samples far outside the source. Start from identity, change one thing at a time.

Map shapes disagree. map_x and map_y must come from the same chain and share a shape; mixing an identity map sized for one image with a distortion built for another gives you a shape error or garbage.

You forgot the final cv2_remap. The maps are not an image. Nothing is rendered until you apply them.

The pack's README is candid that this is a personal project with heavy LLM involvement in the code, sample-tuned example workflows and no promised support. The remap family is one of the better-behaved corners of it - the maths is well-defined and the coordinate convention is documented per node - which is more than you can say for some of the 470 generated wrappers.

Categoryimage/CV/remap

Inputs (1)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASKOnly its width/height are used. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.

Outputs (2)

NameTypeDescription
map_xNPARRAYHxW float32 source-x coordinate per pixel.
map_yNPARRAYHxW float32 source-y coordinate per pixel.