Convert spherical projections to cylindrical projection

Written by Paul Bourke
February 2006

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
-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.

sph2pan -w 800 -v -7.5 dervish_sph.tga

sph2pan -w 800 -v -7.5 -t 60 dervish_sph.tga

sph2pan -w 800 -v -7.5 -t 60 -r 90 dervish_sph.tga