Nodes/comfyui_cv/CV Radial Lens Map
ComfyUI Node

CV Radial Lens Map

Polynomial radial (lens) distortion, like ImageMagick's barrel distort: scales each coordinate's distance to the center by a*r^3 + b*r^2 + c*r + d (r normalized so r = 1 at the nearest edge). Positive b bulges the center outward (barrel/fisheye look), negative b pinches it (pincushion); mixing signs of a and b gives mustache distortion. The inverse form undoes the polynomial with the SAME coefficients (it solves r' * P(r') = r per pixel with a few Newton steps, the technique cv2.undistortPoints uses) - chain both to round-trip a distortion to sub-pixel accuracy. Where the polynomial is not monotonic (extreme coefficients fold the image onto itself) the inverse clamps to the last invertible radius instead of blowing up.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Radial Lens Map
  • map_x
  • map_y
  • map_x
  • map_y
a0.00
b0.15
c0.00
formulapolynomial: r * (a r^3 + b r^2 + c r + d)
d0.00
center_x0.50
center_y0.50
Categoryimage/CV/remap

Inputs (9)

NameTypeDefaultDescription
map_xNPARRAYIncoming source-x coordinate map to distort. Start the chain with 'CV Identity Map'; further remap nodes compose onto it.
map_yNPARRAYIncoming source-y coordinate map (must share map_x's shape - both come from the same chain).
aFLOAT0.00-8–8r^3 coefficient.
bFLOAT0.15-8–8r^2 coefficient: + barrel, - pincushion.
cFLOAT0.00-8–8r coefficient.
formulaCOMBOpolynomial: r * (a r^3 + b r^2 + c r + d)polynomial applies the distortion; inverse undoes it with the same coefficients (chain both to round-trip).
doptFLOAT0.00-8–8Constant term; 0 = auto (1 - a - b - c), which keeps the r = 1 circle fixed.
center_xoptFLOAT0.500–1Distortion center as a fraction of the width.
center_yoptFLOAT0.500–1Distortion center as a fraction of the height.

Outputs (2)

NameTypeDescription
map_xNPARRAY
map_yNPARRAY