Nodes/opencv-comfyui/OpenCV logPolar_0
ComfyUI Node

OpenCV logPolar_0

The foveal transform that turns rotation and zoom into shifts

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

This is the weird cousin of the polar unwrap. OpenCV logPolar_0 wraps cv2.logPolar, which remaps an image into log-polar coordinates - like the linear polar transform, but the radius axis grows logarithmically instead of linearly. The result is what human foveal vision roughly does: massive resolution in the middle, compressed periphery, and a square image that looks like a vortex had a seizure.

There's a genuinely clever reason this exists. Because the radius is logarithmic, a rotation of the original image becomes a vertical shift in the log-polar image, and a zoom becomes a horizontal shift. Rotating something and having it turn into a translation is the classic trick behind rotation-and-scale-invariant template matching - computer-vision lore that mostly lived in academic papers until someone auto-generated it into a ComfyUI node.

What you'd actually do with it

Realistically, for generative work: creating spiral/vortex distortion effects for stylization, and understanding what's happening inside the image's spatial-frequency structure. If you're doing rotation-invariant matching or foveal-effect overlays, this is the one. If you're generating pretty pictures, it's a novelty filter - but an instant, free one.

The inputs

  • src - NPARRAY. Pack rule: Image2Nparray in, Nparrays2Image out. Comfy IMAGE won't connect.
  • center - the pole, as a string literal: [256, 256] or (width/2, height/2). Parsed with ast.literal_eval; bad syntax → invalid syntax (<unknown>, line 0).
  • M - the log scale, in units of pixels per e-fold. Bigger M compresses the radial detail more. Start around 50100 and tune.
  • flags - INTER_LINEAR = 1 is the interpolation you want; add 8 (WARP_FILL_OUTLIERS) to fill the corners rather than black.

Optional dst - an out-parameter. Skip it. Output is the single nparray.

Install

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

Restart, or install "opencv-comfyui" via ComfyUI Manager (search "opencv"). Requirements: opencv-contrib-python, numpy, torch. No models, no downloads beyond pip.

Common issues

  • Everything looks crushed toward the center. That's the log mapping doing its job - raise M to compress less.
  • Output size surprises. Log-polar output has its own geometry; don't expect source dimensions.
  • invalid syntax - the center literal is malformed.
  • Batch error - batch_size==1 only; use ImageFromBatch (length=1).

One honest sentence: you can absolutely skip this node and never miss it. But it's a great example of why the pack is fun - 600+ raw cv2 functions, auto-generated, all sitting there waiting for the one workflow where they're exactly what you needed.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
centerSTRING
MFLOAT
flagsINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY