Cylindrical Projection
You are given a point in planar image coordinates (centered at optical axis) and need to project it onto a cylindrical surface.
Cylindrical projection wraps the image around a cylinder of radius equal to the focal length:
x′=f⋅arctan(fx) y′=x2+f2f⋅y
Where:
- (x,y) is the input point (relative to image center)
- f is the focal length in pixels
- (x′,y′) is the cylindrical coordinate
Cylindrical projection has two key benefits:
- Rotation around the camera's vertical axis becomes pure horizontal translation
- This simplifies panorama stitching to 1D alignment
Example:
point = (100, 50) f = 500
(98.6939, 49.0098)
Applying cylindrical projection formulas:
-
x' = f × arctan(x/f) = 500 × arctan(100/500) = 500 × arctan(0.2) = 500 × 0.1974 (radians) = 98.6939
-
y' = f × y / √(x² + f²) = 500 × 50 / √(100² + 500²) = 25000 / √(10000 + 250000) = 25000 / √260000 = 25000 / 509.902 = 49.0098
Result: (98.6939, 49.0098)
The x coordinate shrinks slightly (100 → 98.69) and y also adjusts.
Constraints:
- point is (x, y) in planar coordinates, centered at image center
- f is the focal length in pixels
- Return (x', y') in cylindrical coordinates
- Round to 4 decimal places
More from CV: Image Alignment and Stitching
You are mapping a 2D image point (x,y) (with origin at the image center) to a cylindrical projection using the given formulas, with the cylinder’s radius equal to the focal length f. This is a direct coordinate transform problem that you’ll apply to each pixel when warping an image for panorama stitching.
1. Background Knowledge (Concepts & Theory)
- Camera and image coordinates A pinhole camera maps 3D scene points onto a 2D image plane. If you place the origin at the optical axis (image center) and measure in pixels, then (x,y) is the offset from the center and f is the focal length in pixels. Under a simple pinhole model, a 3D point on a ray is projected as:
- Cylindrical projection Instead of projecting onto a plane, you can imagine projecting rays from the camera onto a cylinder around the camera with radius f. A ray direction can be parameterized by its horizontal angle θ and vertical elevation relative to the optical axis. Cylindrical projection stores θ along the horizontal axis and a scaled vertical coordinate along the vertical axis. This leads to:
This “unwraps” rotations around the vertical axis into roughly linear horizontal shifts.
- Why panoramas use cylinders When you rotate the camera around its vertical axis, the same scene point moves mostly horizontally on the cylindrical image—essentially as a pure translation in x′. That makes image alignment easier: instead of a full 2D homography, alignment reduces mainly to a 1D horizontal shift, simplifying panorama stitching.
2. Algorithm / Approach Pattern
For this problem type (single-point cylindrical projection):
- Normalize by focal length: Interpret fx as the tangent of a viewing angle.
- Compute the horizontal angle: Use θ=arctan(x/f), then scale by f to get x′.
- Compute vertical scaling: Account for how vertical rays intersect the cylinder using the length of the ray’s horizontal component x2+f2, then scale y accordingly to get y′.
- Return transformed coordinates: (x′,y′) relative to the cylindrical image’s center.
In a full image warping context, you typically:
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.