Flat stitching for tilt-shift lenses

From PanoTools.org Wiki
Revision as of 15:54, 25 May 2017 by Erik Krause (talk | contribs) (categorized)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In the large format world with technical view cameras it is quite common to have lenses with large image circles (much larger than the sensor) and shift the digital back and then stitch together 2-3 images to a larger image. The lens is held still, so what you do is to simulate a larger sensor size than you have.

For 35mm there are special tilt-shift lenses so you can work with the same methods as with a technical view camera. Canon have the TS-E 24, 45 and 90 mm, and Nikon their PC-E 24, 45 and 85mm. There are also third-party lenses available. For this flat-stitching method it is the shift function of the lens that is relevant, not tilt. Most lenses that provides shift can also do tilt though and if the scene requires a tilted focal plane, you can indeed employ tilt too.

The advantage of flat-stitching instead of having a panorama head and turning the camera and make a rectinear projection is that you have the projection directly in the lens so you don't need to stretch any pixels, so resolution becomes a bit better, despite corner resolution of the lens is a bit lower. In practice it is more a matter of taste though, some just prefer flat-stitching.

Unfortunately the 35mm shift lenses rarely have tripod collars, meaning that the camera body rather than the lens is attached to the tripod. To avoid parallax errors you thus need to have a rail on the camera to compensate for the lens shift, i e when shifting the lens X mm to the right you shift the camera X mm to the left so the lens effectively stands still. Some panorama heads happens allow that type of shifting. Using a focus rail is another option. For indoor scenes with objects within a few meters the parallax error will surely be noticed in stitching, so you need to make sure the lens does not move.

To get as large coverage as possible you should shoot in portrait format (for horizontal panoramas), so you shift along the short side. Thus you may need an L-bracket too.

Theoretically you would not need to use Hugin for this type of stitching, since the lens stands still and the sensor is just moved around inside the image circle there would be perfect fit and no stretching needed so you just need to lay them together in any photo editor. However, in practice there is usually minor precision errors. When adjusting shift between shots, especially if you need to adjust both lens and camera body as for 35mm, there is usually some slight errors making it hard to fit manually. If the tripod and head is not perfectly rigid there may be some additional slight shifts and rolls when adjusting camera body position.

Thus it is nice to be able to use Hugin. Here's how:

  • Take the photos, usually 2 or 3. Assuming RAW format.
  • Develop to 16 bit tiff, using for example RawTherapee
    • Make sure exposure is exactly the same for all images.
    • If you need to use highlight reconstruction which may alter exposure, compensate by lowering exposure slider somewhat so that no value reach maximum (255/65535) but is as close as possible to it, to make sure exposure is exactly the same for all images.
    • Make minimal conversion, no sharpening curves etc, leave the final conversion to after stitching.
    • Save the tiffs with a large color space, prophoto for example, to make sure no color information is clipped.
  • Make the panorama in Hugin
    • Load images
    • Anchor middle image for position (exposure not important, we're not going to use it)
    • Make control points, 3 per image is enough
      • Manual control points are often safer and better than automatic, and you don't need many so it's a quick thing to do
    • Go to optimizer, and do custom optimization:
      • First X parameter for all but the anchor image, optimize
        • We expect largest shifts in the X direction (this workflow assumes horizontal panorama, if it is vertical then start with Y)
        • If shifting would be perfect with no precision errors, this parameter is the only we would have to optimize. In practice we often need a couple of more for best results though.
      • Then add also Y paramater to all but anchor, optimize
      • Then add roll parameter to all but anchor, optimize.
      • You may try adding Z, yaw and pitch too to see if you get better result, but X, Y and roll is often enough.
      • The end result should be very small error, less than 1 pixel.
      • We do no view, barrel or distortion correction, it would make no sense since the images are from different overlapping positions inside the same image circle of the lens which has not moved between shots.
      • Some slightly different order of optimization than described above may work better for you, it all depends on what type of movement error that is introduced when shifting the sensor. Experiment if you don't get expected results.
      • To keep as good image quality as possible (which is likely why we do flat-stitch in the first place), we want as little transformations as possible. If you can do with only X and Y optimizations (no roll), there will be no transformations at all. It is rarely valuable to optimize further if the error is below one pixel.
    • Skip exposure correction
      • That is why we had to be careful to get exactly the same exposure from the raw developer
      • The reason we skip exposure optimization is due to the strange vingetting offset etc you get when you shift the lens, Hugin is not designed for compensating shifted lenses.
    • Stitch to desired output, preferably 16 bit tiff
  • Open final tiff image in raw developer and do final color correction, curves, sharpening, vignetting/lens correction etc.