Difference between revisions of "Perspective correction"

From PanoTools.org Wiki
Jump to navigation Jump to search
m (hint to example)
(next part (to be continued))
Line 2: Line 2:
 
This tutorial has no direct relevance to panorama creation. However, perspective correction is an issue for panorama creation as well, if you shoot your images tilted up or down. But please note that it is not necessary to correct the images prior to stitching - this is done in one go with alignment and stitching.
 
This tutorial has no direct relevance to panorama creation. However, perspective correction is an issue for panorama creation as well, if you shoot your images tilted up or down. But please note that it is not necessary to correct the images prior to stitching - this is done in one go with alignment and stitching.
  
Falling lines can be annoying not only in architectural photography. In former times photographers used shift lenses (some times called [http://en.wikipedia.org/wiki/Perspective_correction|Perspective Correction] lenses) to correct for that. These lenses usually are pretty expensive, not available in all needed focal lengths and limited to a certain amount of correction.
+
Falling lines can be annoying not only in architectural photography. In former times photographers used shift lenses (some times called [http://en.wikipedia.org/wiki/Perspective_correction Perspective Correction] lenses) to correct for that. These lenses usually are pretty expensive, not available in all needed focal lengths and limited to a certain amount of correction.
  
 
Panotools are able to simulate a shift lens in terms of geometry (obviously they can't simulate it in terms of [[Depth of Field]]). There are some easy and straightforward techniques to achieve perspective correction depending on the direction the camera was tilted.
 
Panotools are able to simulate a shift lens in terms of geometry (obviously they can't simulate it in terms of [[Depth of Field]]). There are some easy and straightforward techniques to achieve perspective correction depending on the direction the camera was tilted.
  
 
==Prerequisites==
 
==Prerequisites==
You need either PTGui or hugin for this tutorial. The usage of these programs is more or less identical although names differ sometimes a bit. I'll explain using PTGui and provide a small [[#glossary|glossary]] where the respective hugin names are listed.
+
This tutorial uses [[PTGui]], but any of the [[GUI front-ends]] would do. The usage of these programs is more or less identical although names differ sometimes a bit and some fields are in different locations. For hugin there is a similar tutorial here: [http://hugin.sourceforge.net/tutorials/architectural/en.shtml]
  
In all cases you start a new project and add the image you want to correct by pressing the [[#Add - Add individual image|Add]] button.  
+
In all cases you start a new project and add the image you want to correct by pressing the '''Add''' button.  
  
Go to [[#Lens parameters - Camera and Lens|Lens parameters]] tab and choose your lens type (presumable '''normal (rectilinear)'''). Enter the approximate '''Field of View''' if not already read from [[Exif]] data (it's not necessary to have it exact). If you already have lens correction parameters enter them in the '''a''', '''b''' and '''c''' field else enter 0.0 for each.
+
Go to '''Lens parameters''' tab and choose your lens type (presumable '''normal (rectilinear)'''). Enter the approximate '''Field of View''' if not already read from [[EXIF]] data (it's not necessary to have it exact). If you already have lens correction parameters enter them in the '''a''', '''b''' and '''c''' fields else enter 0.0 for each.
  
In [[#Panorama settings - Stitcher|Panorama settings]] tab choose '''Rectilinear ('flat')''' as output.
+
In '''Panorama settings''' tab choose '''Rectilinear ('flat')''' as output.
  
 
== Camera tilted up or down ==
 
== Camera tilted up or down ==
 +
=== Camera level to the horizon ===
 
{| border="0" cellpadding="2" cellspacing="0" align="right"
 
{| border="0" cellpadding="2" cellspacing="0" align="right"
|[[Image:PC_img01.jpg|rigth|thumb|100px|right|Falling lines example © Daniela D�rbeck]]
+
|valign="top"|[[Image:PC_img01.jpg|thumb|100px|right|Falling lines example © Daniela D�rbeck]]
|[[Image:PC_img02.jpg|rigth|thumb|100px|right|corrected image in Panorama Editor]]
+
|valign="top"|[[Image:PC_img02.jpg|thumb|100px|right|corrected image in Panorama Editor]]
 
|}
 
|}
If the camera was level to the horizon, one pair of vertical control points is enough to correct for falling lines. Go to '''Control points''' tab and set a point to the top of something vertical in your image in the left pane and one at the bottom of the same vertical structure in the rigth pane. Be sure to choose '''Vertical line''' as control point type.
+
If the camera was level to the horizon, one pair of vertical control points is enough to correct for falling lines. Go to '''Control points''' tab and set one point to the top of something vertical in your image in the left pane and one point at the bottom of the same vertical structure in the rigth pane. Be sure to choose '''Vertical line''' as control point type.
  
On [[#Optimizer|Optimizer]] tab check '''Interface: Advanced'''. Check '''Pitch''' and '''Use control points of:''' for '''Image 0'''. All other fields are unchecked. Then press [[#Run Optimizer - Optimize now|Run Optimizer]] and confirm the following dialog.
+
On '''Optimizer''' tab check '''Interface: Advanced'''. Check '''Pitch''' and '''Use control points of:''' for '''Image 0'''. All other fields are unchecked. Then press '''Run Optimizer''' and confirm the following dialog.
  
Open [[#Panorama Editor - Panorama preview|Panorama Editor]] and press the [[#Fit panorama|Fit panorama]] button. The image should be corrected and shifted up or down with black space below or above. You can cut the frame using the small sliders at the bottom and right side of the window. However, you can't crop away the additional black space.
+
Once you're done proceed as described under [[#Adjust output|Adjust output]].
  
Once you're done proceed as described under [[#Save and Exit|Save and Exit]].
+
In the example image I set one point at the middle light at the top of the tower, another approximately in the middle as far down as possible. Click the thumbs to enlarge.
 +
{{clr}}
 +
 
 +
=== Camera rotated ===
 +
{| border="0" cellpadding="2" cellspacing="0" align="right"
 +
|valign="top"|[[Image:PC_img03.jpg|thumb|100px|right|Falling lines example 2 © Erik Krause]]
 +
|valign="top"|[[Image:PC_img04.jpg|thumb|100px|right|Image in Control Point Editor]]
 +
|-
 +
|valign="top"|[[Image:PC_img05.jpg|thumb|100px|right|Corrected image in Panorama Editor]]
 +
|}
 +
If the camera was rotated you need at least two vertical lines control point pairs. Go to '''Control points''' tab and set two point pairs on some vertical structures well apart from each other. For each line set a point in one pane at the bottom and in the other pane at the top of the same vertical structure. Be sure to choose '''Vertical line''' as control point type.
 +
 
 +
In order to correct for perspective and image rotation you must optimize '''Pitch''' and '''Roll'''.
 +
 
 +
On '''Optimizer''' tab check '''Interface: Advanced'''. Check '''Pitch''' '''Roll''' and '''Use control points of:''' for '''Image 0'''. All other fields are unchecked. Then press '''Run Optimizer''' and confirm the following dialog.
 +
 
 +
Once you're done proceed as described under [[#Adjust output|Adjust output]].
  
In the example image I set one point at the middle light at the top of the tower, another approximately in the middle as far down as possible. Click the thumbs to enlarge.
+
In the example image I set one point pair at top and bottom of the leftmost edge of the altar and one point pair at the rightmost edge. Click the thumbs to enlarge.
 
{{clr}}
 
{{clr}}
 +
 +
==Adjust output==
 +
In any case the image will be shifted in some direction, hence the output image will be larger. The width and heigth of the output image can be adjusted, but it is not possible to crop either side individually in PTGui.
 +
 +
Open '''Panorama Editor''' (Ctrl+E) and press the '''Fit panorama''' (Ctrl+F or menu: Edit -> Fit panorama) button. This will automatically adjust the output area to fit the corrected image.
 +
 +
You should see the image shifted in some direction with the empty space filled with black. You can adjust the width and heigth of the frame using the small sliders at the bottom and right side of the window (actually you adjust the output [[Field of View]]). The additional black space must be cropped in some image editor.
 +
 +
  
 
(to be continued)
 
(to be continued)
  
==Glossary==
 
<h4>PTGui - hugin</h4>
 
PTGui names left mentioned in the text correspond to hugin names right.
 
====Add - Add individual image====
 
====Lens parameters - Camera and Lens====
 
Note that in hugin you must select the image in the list first.
 
====Panorama settings - Stitcher====
 
====Optimizer====
 
In hugin choose '''the custom parameters below''' from the '''Optimize''' drop list.
 
====Run Optimizer - Optimize now====
 
====Panorama Editor - Panorama preview====
 
In PTGui: Ctrl+E - in hugin: Ctrl+P
 
====Fit panorama====
 
In PTGui: Ctrl+F or menu: Edit -> Fit panorama - in hugin: '''Fit'''
 
  
 
<small>--[[User:Erik Krause|Erik Krause]] 18:38, 23 Jul 2005 (EDT)</small>
 
<small>--[[User:Erik Krause|Erik Krause]] 18:38, 23 Jul 2005 (EDT)</small>

Revision as of 22:27, 25 July 2005

Intro

This tutorial has no direct relevance to panorama creation. However, perspective correction is an issue for panorama creation as well, if you shoot your images tilted up or down. But please note that it is not necessary to correct the images prior to stitching - this is done in one go with alignment and stitching.

Falling lines can be annoying not only in architectural photography. In former times photographers used shift lenses (some times called Perspective Correction lenses) to correct for that. These lenses usually are pretty expensive, not available in all needed focal lengths and limited to a certain amount of correction.

Panotools are able to simulate a shift lens in terms of geometry (obviously they can't simulate it in terms of Depth of Field). There are some easy and straightforward techniques to achieve perspective correction depending on the direction the camera was tilted.

Prerequisites

This tutorial uses PTGui, but any of the GUI front-ends would do. The usage of these programs is more or less identical although names differ sometimes a bit and some fields are in different locations. For hugin there is a similar tutorial here: [1]

In all cases you start a new project and add the image you want to correct by pressing the Add button.

Go to Lens parameters tab and choose your lens type (presumable normal (rectilinear)). Enter the approximate Field of View if not already read from EXIF data (it's not necessary to have it exact). If you already have lens correction parameters enter them in the a, b and c fields else enter 0.0 for each.

In Panorama settings tab choose Rectilinear ('flat') as output.

Camera tilted up or down

Camera level to the horizon

Falling lines example © Daniela D�rbeck
corrected image in Panorama Editor

If the camera was level to the horizon, one pair of vertical control points is enough to correct for falling lines. Go to Control points tab and set one point to the top of something vertical in your image in the left pane and one point at the bottom of the same vertical structure in the rigth pane. Be sure to choose Vertical line as control point type.

On Optimizer tab check Interface: Advanced. Check Pitch and Use control points of: for Image 0. All other fields are unchecked. Then press Run Optimizer and confirm the following dialog.

Once you're done proceed as described under Adjust output.

In the example image I set one point at the middle light at the top of the tower, another approximately in the middle as far down as possible. Click the thumbs to enlarge.

Camera rotated

Falling lines example 2 © Erik Krause
Image in Control Point Editor
Corrected image in Panorama Editor

If the camera was rotated you need at least two vertical lines control point pairs. Go to Control points tab and set two point pairs on some vertical structures well apart from each other. For each line set a point in one pane at the bottom and in the other pane at the top of the same vertical structure. Be sure to choose Vertical line as control point type.

In order to correct for perspective and image rotation you must optimize Pitch and Roll.

On Optimizer tab check Interface: Advanced. Check Pitch Roll and Use control points of: for Image 0. All other fields are unchecked. Then press Run Optimizer and confirm the following dialog.

Once you're done proceed as described under Adjust output.

In the example image I set one point pair at top and bottom of the leftmost edge of the altar and one point pair at the rightmost edge. Click the thumbs to enlarge.

Adjust output

In any case the image will be shifted in some direction, hence the output image will be larger. The width and heigth of the output image can be adjusted, but it is not possible to crop either side individually in PTGui.

Open Panorama Editor (Ctrl+E) and press the Fit panorama (Ctrl+F or menu: Edit -> Fit panorama) button. This will automatically adjust the output area to fit the corrected image.

You should see the image shifted in some direction with the empty space filled with black. You can adjust the width and heigth of the frame using the small sliders at the bottom and right side of the window (actually you adjust the output Field of View). The additional black space must be cropped in some image editor.


(to be continued)


--Erik Krause 18:38, 23 Jul 2005 (EDT)