The General Panini Projection
The general Panini projection is an adjustable projection, or more properly a parameterized family of projections, that can render convincing simulated perspectives on fields of view up to 150 degrees wide, or even wider in some cases. It was first implemented in early 2009 in the panorama viewer, Panini, and in limited form in the panotools library. This page describes the improved version that was added to the panotools library in January 2010.
For best results the general Panini projection needs to be used interactively: you adjust the control parameters until your image looks just right. The 'fast' preview window in the 2010 version of hugin works well for that most of the time but has a few problems. However, it is possible to get equally good results with the 'slow' preview window, and with experience, even with scripts for the command line tool, PTmender.
The general Panini projection is suitable for subjects that have a lot of architectural content, especially interiors. It works best for views with a single central vanishing point -- straight down a city street, or the aisle of a church, for example. However it is good for oblique interior and street views too. It is not suitable for close-up exterior views of buildings, especially when looking toward a corner of the building.
A Panini perspective seems to combine telephoto and wide angle views in one image. Compared to a rectilinear view of the same width, the center is magnified and depth seems flattened (telephoto effects). At the same time, the field of view can be very wide, without the peripheral distortion (stretching) that is so noticeable when a rectilinear perspective is pushed too far. And somehow the view tends to look even wider than it actually is.
The general Panini projection renders vertical straight lines as straight, a prerequisite for any perspective view. Its basic form also renders radial lines through the view center as straight. That creates a convincing perspective illusion when there is a vanishing point at or near view center. But it renders horizontal straight lines as curves, with the strongest curvature in the middle of the image.
That makes many images seem to 'bulge' at top and bottom center. Adding a vertical adjustment, designed to reduce that curvature, can make many central perspectives look more natural and improve the perspective illusion when the vanishing point is off-center. We call those adjustments 'squeezes' because early implementations actually compressed the middle of the image. Current versions stretch the sides instead.
There are two kinds of squeeze, 'hard' and 'soft'. A hard squeeze can fully straighten horizontal lines, but only works on fields of view well under 180 degrees. A soft squeeze provides less complete straightening but works for wider fields of view.
The general Panini projection is controlled by three parameters.
The main parameter, called compression and labelled 'Cmpr' in the hugin preview, has a range of 0 to 150 (you can think of that as percent). It adjusts the overall form of the projection between the completely uncompressed rectilinear projection (Cmpr = 0) and the maximally compressed orthographic cylindrical projection (Cmpr = 150) with the standard Pannini (stereographic cylindrical) projection at Cmpr = 100.
The maximum horizontal field of view varies with compression, from 160 degrees at Cmpr = 0 to 320 degrees at Cmpr = 100, then back to 180 degrees at Cmpr = 150. Hugin's FOV sliders automatically respect these limits. If you enter an infeasible hfov value in a script (for PTmender, for example) the actual field of view will be the largest feasible value.
Two secondary parameters, labeled 'Tops' and 'Bots', control vertical 'squeeze' adjustments applied to the top and bottom halves of the image, for the purpose of reducing the curvature of horizontal lines. These have a range of -100 to 100. There is no squeeze when the parameter is zero. Positive values invoke a 'hard' squeeze, that can exactly straighten horizontal lines, but only over a limited range of about 160 degrees. Negative values invoke a 'soft' squeeze that works for wider fields of view but cannot eliminate all curvature.
Reducing the curvature of horizontal lines comes at the cost of increasing the curvature of radial lines. The effect is strongest far from image center. It can be hard to see at a field of view of 120 degrees but becomes very evident when the field of view is 150 degrees or more.
Distortionless Wide-Angle Photos
One of the best uses of the general Panini projection is simulating rectilinear perspective, without peripheral distortion, on fields of view typical of wide angle to super-wide angle camera lenses, say in the range of 75 to 120 degrees. A compression well under 100 is usually enough, plus a hard squeeze to straighten prominent transverse lines. The appropriate squeeze strength depends on the inclination of those lines: 100% if they are horizontal, less as the slope increases.
Perspective Views from Fish-Eye Photos
Hugin with the general Panini projection is an excellent 'de-fishing' tool. Load a fisheye image; adjust pitch and roll angles to make all vertical lines vertical in the view, then adjust the g.P. parameters for a good perspective. Note that you can now adjust pitch and roll by dragging in the fast preview window.
If vertical lines look curved in the general Panini projection view, you should adjust the lens focal length or FOV until they are straight. The same applies to horizontal lines when the squeeze parameter is set to 100%. For even better results, you could set the lens fov and a,b,c distortion parameters to values that were optimized on a well-aligned spherical panorama made with the same lens.
Ultra-Wide Views from Panoramas
With a properly aligned panorama as the source image, the general Panini projection can be used like any other projection to render views in various directions, but it is best for views where the line of sight is level, not tilted up or down. You can use hugin's cropping feature to eliminate unwanted areas at the top or bottom, however to get a perfectly framed view it may be necessary to crop the rendered image later.
It is often possible to render a convincing view 180 degrees or more wide, where the subject has a strong central perspective. Only the soft squeeze can be used on such wide fields, as the hard squeeze has singularities (goes to infinity) at +/- 90 degrees.
Your panotools and hugin must have been built after 20 January 2010, from panotools source version SVN 1237 or later and hugin source version SVN 4920 or later.
In the first versions of hugin that support the general Panini projection, the 'fast' preview window has trouble displaying 'squeezed' general Panini views when stitching a panorama from mulitple images, but works correctly when reformatting a single image. The 'slow' preview window shows the true view in all cases; use it if the fast preview display seems garbled.
-- T. K. Sharpless, 18 January 2010 - 20 January 2010 --