Converting an equirectangular image to a cylindrical panoramic projectionWritten by Paul Bourke
Update (Aug 2018): Added panoramic vertical shifting
Update (March 2023): Add remap filters for ffmpeg
The source code implementing the projections below is only available on request for a small fee. It includes an invitation to convert an image of your choice to verify the code does what you seek. For more information please contact the author.
In what follows I describe software for extracting a cylindrical panorama from an equirectangular (spherical) projection. There are various reasons why one might want to do this, the driver here is creating images for large scale cylindrical displays. Diagramatically, for some displays and 360 cameras used by the author this diagram illustrates the geometry.Usage string
sphere2pano [options] sphericalimagename Options: -t n vertical FOV of panoramic, 0...180 (default: 60) -a n set antialias level, 1, 2 or 3 typical (default: 2) -w n width of the output panorama image (default: 2048) -o s output file name (default: determined internally) -x n tilt angle (degrees), default: 0 -y n roll angle (degrees), default: 0 -z n pan angle (degrees), default: 0 -l flip in longitude (default: off) -f create remap filters for ffmpeg (default: off) -d enable verbose debugging mode
Like an equirectangular projection, the horizontal axis of a cylindrical panorama is equal steps of longitude. However the vertical axis resembles a perspective projection. As such, while an equirectangular can represent from -90 to 90 degrees in latitude, a cylindrical panorama becomes increasingly inefficient after about 140 degrees vertical field of view (FOV).
The following equirectangular will be used to illustrate the basic transformations.
The following is a 45 degree vertical FOV.
sphere2pano -w 4096 sample.jpg
The following is a 70 degree vertical FOV.
sphere2pano -w 4096 -t 70 sample.jpg
As is usual with such mapping the process is performed in reverse, that is, one considers each pixel in the output cylindrical panorama and computes the best estimate in the input image, the equirectangular in this case. Antialising is performed here using a straightforward supersampling of each output pixel.
Older version: Convert spherical projections to cylindrical projectionWritten by Paul Bourke
The following utility was written to convert spherical projections into cylindrical projections. Of course only a slice of the spherical projection is used. The original reason for developing this was to convert video content from the LadyBug-3 camera (spherical projection) to a suitable image for a 360 cylindrical display. This a command line utility and as such straightforward to script to convert sequences of frames that make up a movie.
sph2pan [options] sphericalimagename Options: -t n set max theta on vertical axis of panoramic, 0...90 (default: 45) -a n set antialias level, 1 upwards, 2 or 3 typical (default: 2) -w n width of the spherical image -r n horizontal rotation angle (default: 0) -v n vertical rotation angle (default: 0) -f flip insideout (default: off)
Sample spherical projection (from the LadyBug-3)
Click for original image (5400x2700 pixels).
As with all such image transformations, one considers a point in the destination image noting that the point may be a sub pixel (required for supersampling antialiasing). This point corresponds to a vector in 3D space, this is then used to determine the corresponding point in the input image. Options such as rotations and flips correspond to operations on the 3D vector.Sample derived cylindrical projections
The following show example transformations illustrating some of the more important options. In particular the ability to specify the vertical field of view and the vertical offset for the cylindrical image.