Nodes/opencv-comfyui/OpenCV logPolar_1
ComfyUI Node

OpenCV logPolar_1

OpenCV logPolar_1 — same foveal transform, different overload number

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV logPolar_1
  • src
  • dst
  • nparray
center
M
flags

Let's get the boring truth out first: logPolar_1 and logPolar_0 are interchangeable. The pack generates _0/_1 pairs for every function because OpenCV's type stubs declare each one twice (for MatLike and for OpenCL UMat), and the generator numbered the overloads. Both wrappers call the same cv2.logPolar and behave identically. Pick the one that's already on your canvas.

What the function does is more interesting. It remaps the image into log-polar coordinates: angle on one axis, log-of-radius on the other. The magic property: rotate the source and the result shifts vertically; zoom the source and it shifts horizontally. That transform-to-translation trick is why log-polar is the standard tool for rotation/scale-invariant matching in classic CV - and now you can reach it from a workflow graph.

The inputs you set

  • src - NPARRAY. You know the drill by now: Image2Nparray in, Nparrays2Image out.
  • center - string literal pole: [256, 256] or (w/2, h/2). Parsed by ast.literal_eval; malformed input is the pack's invalid syntax (<unknown>, line 0).
  • M - logarithmic scale in pixels per e-fold. This is the main "feel" knob; higher M spreads radial detail out, lower crushes it.
  • flags - 1 for INTER_LINEAR, plus 8 (WARP_FILL_OUTLIERS) if you want the corners filled instead of black.

The optional dst out-parameter is one of the pack's call-by-reference leftovers - leave it alone. Output is a single nparray; it's a float remap, so expect it to look flat/hazy until you normalize or preview via Nparrays2Image.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart. Or ComfyUI Manager → "opencv". Dependencies are opencv-contrib-python, numpy, torch - nothing else, no model files.

Troubleshooting

  • Output is black in the corners - add flag bit 8 to fill them.
  • Too much or too little radial detail - that's M; tune it, there's no "right" value.
  • invalid syntax - the center string is bad. Verify brackets/parens and no stray text.
  • Batch error - Only images with batch_size==1 are supported!ImageFromBatch, length=1.

That's honestly the whole node. Don't overthink which variant to use - the pack's _0/_1 duplication is a quirk of its auto-generation, not a meaningful choice. If a foveal/vortex remap fits your workflow, logPolar_0 and logPolar_1 are the same door.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
centerSTRING
MFLOAT
flagsINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY