Greg's aligning images with Hugin
Greg's photography pages
Greg's photo albums
Greg's photos
Greg's photo index
Groogle
http://dunham.org/grog/wip/graphics-work-in-progress-580482.gif
Work in progress

In March 2011 I tried in vain to align 3 images with Hugin so that I could compare them with mouseover image manipulation (run the mouse cursor over the images below to see what this means).. The main problem was that one of the images was taken at a different focal length, so they didn't line up. I asked on the Hugin mailing list, but didn't get the answers I wanted. In February 2013 I finally worked it out—I thought. Since then I've discovered a number of cases where this method didn't work, and I'm still trying to work out when it does and when it doesn't. Read on and try it; feedback more than welcome.

Here's what you need to do, based on the images I took 2 years before. As you can see, they're not perfectly aligned with each other. Further down are versions which are correctly aligned. Run the mouse cursor over the images to compare with the following image, or click on the images for larger versions:


https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-before-orig.jpeg
Image title: Verandah before orig          Dimensions:          4032 x 3024, 2400 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 
https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-during-orig.jpeg
Image title: Verandah during orig          Dimensions:          4032 x 3024, 2432 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 
https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-after-orig.jpeg
Image title: Verandah after orig          Dimensions:          4032 x 3024, 2480 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 

In this article, all images are shown in relatively small format. Click on an image up to 3 times to enlarge it.

The steps are:

  1. Load the images into Hugin, of course.

  2. In the Photos tab, select Create control points. Depending on the images, CPfind or panomatic is better. In this particular example, CPFind did not find any control points between the middle image and the other two.


    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-1.gif
    Image title: Hugin 1          Dimensions:          1920 x 1080, 70 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

       
    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-1-detail.gif
    Image title: Hugin 1 detail
    Dimensions: 719 x 147, 8 kB
    Dimensions of original: 719 x 147, 8 kB
    Display this image:
    thumbnail    hidden   alone on page
    Display all images on this page as:
    thumbnails    this size
    Show for Sunday, 10 February 2013:
    thumbnails    small images    diary entry
  3. Check the results in the Control Points tab. If, as here, the images are of different sizes, the results will not be very good:


    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-2.gif
    Image title: Hugin 2          Dimensions:          1920 x 1080, 1120 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     

    To confirm, press F3 to get the control point table, then select the head of the column Distance to see the control point errors in descending order:


    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-3.gif
    Image title: Hugin 3          Dimensions:          924 x 673, 36 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     
  4. Save the project file. If things go wrong in the next step, you can reload it and try again with other parameters.

  5. In the Optimize section of the Photos tab, select Positions and View (y,p,r,v) and Calculate!:

     
    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-5.gif
    Image title: Hugin 5
    Dimensions: 446 x 292, 24 kB
    Dimensions of original: 446 x 292, 24 kB
    Display this image:
    thumbnail    hidden   alone on page
    Display all images on this page as:
    thumbnails    this size
    Show for Sunday, 10 February 2013:
    thumbnails    small images    diary entry
     
    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-6.gif
    Image title: Hugin 6
    Dimensions: 405 x 232, 14 kB
    Dimensions of original: 405 x 232, 14 kB
    Display this image:
    thumbnail    hidden   alone on page
    Display all images on this page as:
    thumbnails    this size
    Show for Sunday, 10 February 2013:
    thumbnails    small images    diary entry

    If this works, as above, then all is well. But it seems that if the focal lengths are too close together, the optimizer fails, and you get a message like:

     
    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130225/big/optimizer-fail.gif
    Image title: optimizer fail
    Dimensions: 475 x 256, 12 kB
    Dimensions of original: 475 x 256, 12 kB
    Display this image:
    thumbnail    hidden   alone on page
    Display all images on this page as:
    thumbnails    this size
    Show for Monday, 25 February 2013:
    thumbnails    small images    diary entry

    If this happens, you can try selecting Positions (y, p, r), but in my experience this doesn't often work. I don't have a solution for this case.

    Another case where this doesn't work is if the images have been taken from a slightly different position. In this case, the selection Positions and Translation (y,p,r,x,y,z) might work. In general there's room for experimentation with various optimization parameters.

  6. In the first case, the images now line up well. If necessary, return to the Control Points tab and edit the worst control points.

  7. In the Fast Panorama Preview window, all the images will be on top of each other, and probably far too small:


    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-7.gif
    Image title: Hugin 7          Dimensions:          1920 x 1080, 134 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     
  8. Select Move/Drag and Fit:


  9. https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-8.gif
    Image title: Hugin 8          Dimensions:          1920 x 1080, 736 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     
  10. To get the largest crop that fits all images, select Crop then HDR Autocrop:

  11.  
    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-13-detail.gif
    Image title: Hugin 13 detail
    Dimensions: 444 x 175, 12 kB
    Dimensions of original: 444 x 175, 12 kB
    Display this image:
    thumbnail    hidden   alone on page
    Display all images on this page as:
    thumbnails    this size
    Show for Sunday, 10 February 2013:
    thumbnails    small images    diary entry

    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-13.gif
    Image title: Hugin 13          Dimensions:          1331 x 1063, 688 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     
  12. Move to the Stitcher tab. Select Calculate Optimal Size, deselect Panorama Outputs, and select No exposure correction, low dynamic range in the Remapped Images section, then Stitch!.


    https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20130210/big/Hugin-12-detail.gif
    Image title: Hugin 12 detail          Dimensions:          851 x 833, 56 kB
    Make a single page with this image Hide this image
    Make this image a thumbnail Make thumbnails of all images on this page
    Make this image small again Display small version of all images on this page
    All images taken on Sunday, 10 February 2013, thumbnails          All images taken on Sunday, 10 February 2013, small
    Diary entry for Sunday, 10 February 2013

     

    The image names will be created from the base name you specify (here example) by appending _exposure_layers_ and a sequence number:

    ===========================================================================
    Stitching panorama
    ===========================================================================
    nona  -z LZW -r ldr -e 10.3056 -m TIFF_m -o example_exposure_layers_ -i 0 /var/tmp/huginpto_wEvx1A
    nona  -z LZW -r ldr -e 10.3056 -m TIFF_m -o example_exposure_layers_ -i 1 /var/tmp/huginpto_wEvx1A
    nona  -z LZW -r ldr -e 10.3056 -m TIFF_m -o example_exposure_layers_ -i 2 /var/tmp/huginpto_wEvx1A


    === grog@eureka (/dev/pts/7) ~/Photos/20110330 55 -> ls -l example*                    
    -rw-r--r--  1 grog  lemis  25264578 10 Feb 12:14 example_exposure_layers_0000.tif
    -rw-r--r--  1 grog  lemis  24988642 10 Feb 12:14 example_exposure_layers_0001.tif
    -rw-r--r--  1 grog  lemis  25387168 10 Feb 12:14 example_exposure_layers_0002.tif

Here the results, rearranged in time sequence. Run the mouse cursor over the images to compare with the following image, or click on the images for larger versions:


https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-before.jpeg
Image title: Verandah before          Dimensions:          3810 x 2715, 2736 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 
https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-during.jpeg
Image title: Verandah during          Dimensions:          3810 x 2715, 2720 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 
https://lemis.nyc3.digitaloceanspaces.com/grog/Photos/20110330/big/Verandah-after.jpeg
Image title: Verandah after          Dimensions:          3810 x 2715, 2752 kB
Make a single page with this image Hide this image
Make this image a thumbnail Make thumbnails of all images on this page
Make this image small again Display small version of all images on this page
All images taken on Wednesday, 30 March 2011, thumbnails          All images taken on Wednesday, 30 March 2011, small
Diary entry for Wednesday, 30 March 2011 Complete exposure details

 

If you want to try this with these images, they're here, here and here. In total they're about 8 MB.

In passing, it's worth noting how little you can rely on the information in the EXIF data. According to that data, the first image was taken at a focal length of 23.0 mm, and the other two were taken at a focal length of 21.0 mm. Hugin reports focal lengths of 21.98972 and 21.45713. While these may not be absolutely accurate, the difference in focal length is probably close enough—only 0.5 mm instead of the 2 mm that the EXIF data suggests.


Greg's home page Greg's diary Greg's photos Copyright

Valid XHTML 1.0!

$Id: aligning-with-Hugin.php,v 1.8 2016/07/16 23:31:34 grog Exp grog $