Fisheye to Pannini projections

Written by Paul Bourke
January 2018

See also: Transforming fisheye to ...


The Pannini projection is an approach to creating wide angle views that avoid the stretching that occurs for wide standard perspective views, rectilinear projections. It is named after the Roman painter Gian Paolo Pannini who seems to have used the technique although there is no documentary evidence except a kind of reverse engineering of his paintings. The projection is a variant on a cylindrical projection, that is, vertical structures remain straight in the projection.


The fundamental equations relating positions on the image plane to longitude and latitude, in the so called "basic Pannini projection" are

h = S sin(longitude)
v = S tan(latitude)

Where "h" and "v" are the pixel position in the normalised Pannini image and S is defined as.

As per most image mappings one requires the inverse equations, that is, given a position in the output image (Pannini) what is the best pixel estimate in the input image (fisheye in this case). Derivation is shown below but essentially the same as that by Thomas Sharpless, Bruno Postle, and Daniel German in their original paper. This reverse mapping is what is required for supersampling antialiasing used here, but also for hardware accelerated implementation such as GLSL shaders.

The above allows one to calculate longitude and latitude given normalised image coordinates h and v. The longitude and latitude can then be mapped into the source image coordinate system, a fisheye in this case.

The control variable d determines the degree of the Pannini projection and ranges from 0 upwards. d=0 is just a standard perspective projection, d=1 is cylindrical stereographic projection, and as d tends to infinity the projection tends to a cylindrical orthographic.

Usage line

The implementation documented here creates a Pannini projection from a fisheye photograph. It is designed to work from fisheyes directly off a sensor without any prior processing, as such the center (-c option) and radius (-r option) of the fisheye circle is required along with the FOV at that radius (-s option). If the fisheye has already been centered and cropped then those parameters default to the expected values. Additionally, as in the example below, the fisheye is not perfectly level then it can be corrected by rotating about any axis, see -x, -y and -z options. The x axis to the right (rotation is a tilt), the z axis upwards (rotation is a pan) and the y axis forward (rotation is a roll). Any fisheye lens has a degree of non-linearity, normally most evident towards the rim. This can be corrected with the -p option and a fourth order polynomial, for more information see this. The software uses a straightforward supersampling antialiasing, see -a option.

Usage: fish2pannini [options] fisheyeimage
   -w n        pannini image width, default = 800
   -h n        pannini image height, default = 600
   -t n        field of view (degrees) at d=0, default = 100
   -d n        pannini parameter d, default: 1
   -s n        field of view of fisheye (degrees), default = 180
   -c x y      center of the fisheye image, default is center of image
   -r n        fisheye radius (horizontal), default is half width of fisheye image
   -x n        tilt angle (degrees), default: 0
   -y n        roll angle (degrees), default: 0
   -z n        pan angle (degrees), default: 0
   -a n        antialiasing level, default = 2
   -p n n n n  4th order lens correction, default: off
   -v          verbose mode, default: off


Input sample fisheye image, 180 degrees

Perspective FOV=130, or Pannini d=0

Pannini d=1

The above illustrates the key property of these projections, the horizontal field of view of the Pannini projection on the right is the same as the perspective view on the left except the stretching on the extreme of the image has bee removed. For example the windows on the left of the cathedral are now square and the distant feel of the main alter has been removed.

Pannini d=0.25

Pannini d=0.5

The "basic Pannini projection" has just one parameter to adjust, namely "d" in the equations above. The effect of adjusting d is illustrated here noting that in each case the same horizontal FOV of 130 degrees is maintained.

Pannini d=2

Pannini d=5, nearly cylindrical

And finally a more extreme example of 150 degrees horizontal FOV.

Perspective FOV=150

Pannini d=1

There are a number of methods for straightening off-center horizontal lines, they seem to be arbitrary correction factors to the latitude based upon the longitude. That is, a vertical compression or stretching that varies from the center of the image horizontally. One of many possible approaches has been added here, in the example below note the more horizontally straight structures compared with the uncorrected approach on the left.

Pannini d=1, b=0

Pannini d=1, b=0.75

Personal observation

A final word on terminology. Image mappings from ultrawide angle lenses such as fisheye often use terms like "undistorting", "correcting", "defishing" and so on. It should be recognised that a fisheye image, for example, is no more distorted than any other type of projection. Indeed one could consider a fisheye to be simpler and more natural projection than a rectilinear projection. For example the mathematics is more elegant and in many ways simpler. The fact that lines we expect to be straight straight are not so is a natural consequence of trying to map a 3D object onto a 2D sheet. An effect that is a consequence of fisheye, in the same way as peripheral stretching is a consequence of perspective. Neither are a "distortion".

Giovanni Paolo Pannini

A little history about Giovanni Paolo Pannini (sometimes spelt with a single "n", Panini) and also known as Gian Paolo Panini. He was born in Italy (Piacenza) in 1691 but lived most of his life in Rome from 1711 to 1765. In the context of this document he was known as a "view painter", known as the vedutisti. It is suggested he was educated in the art of perspective and worked mainly in the studio of Benedetto Luti.


Pannini: A New Projection for Rendering Wide Angle Perspective Images. Computational Aesthetics in Graphics, Visualization, and Imaging (2010). Thomas K. Sharpless, Bruno Postle, and Daniel M. German

Optimizing content-preserving projections for wide-angle images. SIGGRAPH '09, pp. 1-9. Carroll R., Agrawal M., Agarwala A.

Correction of geometric perceptual distortions in pictures. SIGGRAPH '95, pp. 257- 264. Zorin D., Barr A.H.