OpenCV logPolar_0
The foveal transform that turns rotation and zoom into shifts
- src
- dst
- nparray
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:Image2Nparrayin,Nparrays2Imageout. ComfyIMAGEwon't connect. - center - the pole, as a string literal:
[256, 256]or(width/2, height/2). Parsed withast.literal_eval; bad syntax →invalid syntax (<unknown>, line 0). - M - the log scale, in units of pixels per e-fold. Bigger
Mcompresses the radial detail more. Start around50–100and tune. - flags -
INTER_LINEAR=1is the interpolation you want; add8(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
Mto compress less. - Output size surprises. Log-polar output has its own geometry; don't expect source dimensions.
invalid syntax- thecenterliteral is malformed.- Batch error -
batch_size==1only; useImageFromBatch(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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| center | STRING | — | |
| M | FLOAT | — | |
| flags | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |