Nodes/opencv-comfyui/OpenCV linearPolar_0
ComfyUI Node

OpenCV linearPolar_0

Unwrap a circular image into a straight line

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

Ever seen one of those "unrolled" circular images - a panorama shot around a pole, or a pie chart peeled open into a strip? That's a linear polar transform, and this node does it. OpenCV linearPolar_0 wraps cv2.linearPolar, which remaps an image from its normal x/y grid into polar coordinates around a point you choose. Circles become lines, spokes become verticals, and it costs nothing but a remap - no model, no VRAM.

It's the kind of node that sounds academic until you have the exact weird problem it solves: turning a round texture into a flat one, straightening the spokes of a wheel, de-rolling a cylindrical panorama, or generating a "polar unwrap" preview for texture work. It's also just fun to throw at a generated image and see what breaks.

How it works

Conceptually: you pick a center point, then every pixel is relocated so that its distance from the center becomes the horizontal axis and its angle becomes the vertical axis. The further out you go, the longer the row. linearPolar maps radius linearly; its cousin logPolar_0 maps radius logarithmically (more on that node separately).

The inputs that matter:

  • src - NPARRAY (yes, the whole pack works on nparrays; Image2Nparray in, Nparrays2Image out).
  • center - the pole of the transform, as a string literal: [width/2, height/2] or an actual value like [512, 512]. ast.literal_eval parses it, so brackets or parens both work; wrong syntax gives the pack's famous invalid syntax (<unknown>, line 0).
  • maxRadius - how far out the transform reaches. Set it roughly to the image's max dimension and you capture the whole frame; smaller crops the unwrap.
  • flags - interpolation and border mode. These are bitwise-combined OpenCV constants. The practical one is INTER_LINEAR = 1; add 8 (WARP_FILL_OUTLIERS) if you want the empty corners filled instead of left black.

Optional dst - an out-parameter you can ignore. The result comes back on the single nparray output.

Install

ComfyUI Manager → search "opencv" → install opencv-comfyui. Or:

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

Restart. Dependencies: opencv-contrib-python, numpy, torch. No models.

Common issues

  • The output isn't the size you expected. The polar remap can produce non-square results - the width is driven by maxRadius and the angles. Don't assume it matches the source.
  • Corners come out black or stretched. Tune maxRadius and add WARP_FILL_OUTLIERS (bit 8) to the flags.
  • invalid syntax - check your center literal.
  • Batch error - the pack is batch_size==1 only; slice with ImageFromBatch before converting.

Honest take: you will almost certainly not need this for ordinary SD/Flux work. It lives in the pack's "small and quick transformations" lane, and it's great there - when a round object needs flattening, nothing else in ComfyUI does it in one node.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
centerSTRING
maxRadiusFLOAT
flagsINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY