A Quick and Dirty Hugin Panoramic Stitcher Tutorial

 In General, Picture

I used to write for a magazine that had several articles in each issue called “Quick and Dirty.” They covered many topics, but the main goal of each article concentrated on accomplishing a complicated goal quickly with high quality results. The author’s goal was to write about the subject quickly, clearly, simply, and produce a result that was as good as if not better than anything else written on the subject.

As, I’ve ventured into the world of 360 degree by 180 degree panoramic stitching; I’ve read many good tutorials, many way- to-deep tutorials, and a ton of very very bad tutorials. Hopefully, I’ll be able to shed some light on panoramic stitching in a quick and dirty way. This article concentrates on 360 x 180 degree panoramic creation, which creates the type of image that requires a java viewer or QuickTime for Internet viewing, and it puts the viewer in the center of the image for a VR Tour experience. But its basic essentials can be used for any type of image stitching. It will be divided into the following parts: Tools required, shooting the pictures (briefly), setting up the images, setting the lens up, using control points, optimizing your stitching files, stitching for java viewers, and the Nadir Image. I hope this helps you enter the enjoyable practice of 360 x 180 panoramic stitching.

brulethree_web.jpg, 27 kB

This 360×180 degree image was created with Autostitch and a Nikon D70 plus a 12-24 DX lens.


Tools Required for VR Tour Style Panoramic Stitching

The following tools are those that I use when making panoramic images.

Hardware Notes

The listed tools above are based on Nikon, which is what I use. You can create panoramic images with any camera system, including films. I’ve created panoramas with Velvia before. It just requires an additional piece of equipment, called a film scanner. Minolta makes a $300 film scanner, which would work nicely for the quality that we require. Don’t worry if you use another camera or lens combo, because there is an easy way to calibrate this set-up to your system.

The panoramic head is the tricky tool in this process. The 360 Precision head allows a template to be created, which then allows easy stitching of any images made from this tripod head, but if you’re just getting started then you could make a simple wooded panoramic tripod head, such as the one described on my blog.

Software

I choose free software, mainly, because the current level of free software is good, and it helps maintain a high bottom line. Plus free is good. Helmut Dersch developed panorama Tools, and this tool offers us two tools which are required for this project. (One if you use autostitch.) The first is PT Stitcher, which is the work horse used my Hugins, and the second is PT Editor, which we will use to add in the Nadir point for our images. A Nadir point is simply a picture of the ground under your tripod.

PTLens is a piece of software written for correcting distortions in lenses. It uses the same .dll file as Panorama Tools. We’re actually not going to use the software; we just need the excellent lens file that comes with the program.

The next file we need is the pano12.dll file. This is a required file to make Panorama Tools work. Due to a patent, many versions of this file are unable to handle stitching from fisheye lenses, so if you have one of those, you’ll have to find the version of this file that supports them. Otherwise, the current version of this file will be fine.

Then the last piece of software needed is a stitching tool. I recommend two: Hugin or Autostitch. The former is a front-end for Panorama Tools. It makes PT accessible to mere mortals whose brains don’t function in the land of quantum mechanics and Calculustrigimonicalphisicspudgunfabmathicatastic. The later tool, Autostitch, does everything for you, but sometime doesn’t work even though you did everything exactly the same. It is currently free, but it is only a working demo that expires every now and then. Hugin, on the other hand, is free and I believe GPL 2 licensed. Free, supported by constant development and more capable then Autostitch and produces better images, but more complex. You pick.

Enblend is a helper program for Hugins that will blend the image nicely when you are ready to stitch.

Installation of the Software

After you download all the software, make sure that you install everything per the instructions that come with the software. The one exception is that we don’t need anything from the PTLens program other than the Lens Profiles. I take no responsibility for any problems that installation of these programs on your computer may cause. I haven’t had problems, but then again, my computer isn’t yours.

Shooting the Pictures

Before you shoot the pictures, you must calibrate your tripod head. If you are using the 360 Precision Head, then you’re set to go. No calibration needed, because the head has been built for your specific lens and camera set-up.

Calibrate a Panoramic Tripod Head

To calibrate your head, you need to find the nodal point for the tripod. The nodal point is the point that centers on the entrance pupil of a lens. The entrance pupil of the lens is the point at which light comes together as a pinpoint and flips inside the lens. Essentially, by finding this point and spinning around this point, if the lens were perfect without any distortion, all our images would line up perfectly. In fact, if we were using a pinhole camera, and spinning around the pinhole, we would indeed have easy to stitch images.

To find this so-called nodal point you should carry out an easy to accomplish experiment. Level your tripod head. Put a broom close to the camera and anchor it so it is straight up, and then take another broom and walk 20 feet or so and anchor that one so it is straight up. Have someone looking through the camera as you do this. Put the second broom so it is hiding behind the first when you look through the viewfinder. Now rotate your tripod head. The goal is to slide your camera back and forth on the tripod head until the far-away broom stays behind the front broom as you rotate the tripod head. When you have accomplished this, you will have found this point. Note: You will also have to make sure the lens is centered side to side over the rotation point of your tripod.

Shooting the Pictures

After you have calibrated your tripod head, you are set to go and shoot the pictures. Shooting the pictures is actually pretty easy now if you follow these steps:

  1. Check that your zoom is set to the correct focal length.
  2. Level the tripod head.
  3. Level the camera if needed.
  4. Set your camera’s WB to one static setting. (I use Cloudy.)
  5. Set your camera’s exposure to manual.
  6. Rotate the camera while looking at the exposure guide. Adjust the exposure for an equal amount of overexposure and underexposure for the most extreme readings. I always lean towards underexposure, because blown digital highlights look bad.
  7. Then shoot the images at equal distances apart from each other with about 20% overlap, and rotate clockwise. For 12mm, I shoot 10 images level, 10 up at an angle, and 10 down at an angle when using Autostitch, and only 8 images in each direction when using Hugin. For the 10.5, I shoot two images down and opposite each other, one up, and, currently 8 (I’m waiting for a part for my 360 Precision Tripod Head), and soon 6 (after I get the part.) Autostitch cannot handle this lens, but Hugins does it perfectly.
  8. Shoot quickly using a remote cord or an IR remote to minimize vibration from press the shutter release.
  9. After shooting the pictures from the tripod, mark the point directly below the tripod, note how high the camera should be held on the swing arm for a downward picture, move the tripod out of the way, hold the camera at the right height above the marked point and shoot a picture. This isn’t required if you restrict you panoramic image viewer from looking down. Or if you want your logo to be displayed when people look down in the images, or if you are over a uniform ground and can clone it in later.

pano1.jpg, 26 kB

Some Panos Work better as a single height

Setting Up the Images For Autostitch

Setting up the images is different for each software that you are going to use. If you are going to use Autostitch, convert the images to jpegs, and open them by selecting them all inside of Autostitch. The program will work for a bit and then will come up with a draft images. If it looks good, then change the stitching setting to however wide in pixels you want your final image to be (or select the percent of all the images you want it to be. Beware that at 100% you may find your computer doesn’t have the memory or power to do the stitching), and change the jpeg setting to 100. This provides the absolute best compression for your images. Autostitch already softens images, so beware.

Setting Up the Images For Hugins

The Downward Images for the 10.5 DX or Full Frame Fisheye

To set up the images for Hugins, the first thing to do is open the two bottom images in your photo-editing program. Then drag one over top of the other, you may want to set the blending mode to difference so you can align the images to account for sensor shift (In cameras, sometimes the sensors are not in the exact center, which is were they should be.) After you get as close as an alignment as possible, set the blending mode to normal, select your eraser tool and erase the tripod arm that you see. Then save the image as bottom.

Loading the Other Images

For the rest of the images, open up Hugins, and load your images into the program. I like to work one row at a time, and by getting the level row finished before doing your up and down rows, you may find it easier. I do. So, load the level row into the program, and after they show up in the image box, then select the first image. There are three Image Orientation parameters that we are going to change: yaw, pitch, and roll.

The yaw for this first row is probably the most important. This is the degrees of rotations that you did for each image. For if you used eight images (360/8=45), you should enter the yaw for the first image as 0, then the next images: 45, 90, 135, -180, -135, -90, and -45. Regardless of the tripod head you are using, these will probably not be the final numbers, but it gives us a good starting point for stitching. For the first row, pitch will be (as long as you leveled perfectly) be 0, and roll should be 0 if your tripod head is perfectly level, and your tripod head has a perfect right angle between the base of the “L” and the arm of the “L.” And your sensor is installed perfectly. This probably won’t happen, so don’t worry about it right now. Just enter 0 in the pitch and roll for each image.

For the up and down images, you do the yaw and roll the same as before, but you need to figure out the pitch, which is the angle at which you shot the images up or down. Down is in the negatives and up is in the positives. For the 10.5 DX lens, I use the settings of -45, -90, and -90 for the bottom image and -45, 90, and -90 for the top image, and it works perfectly without finding control points. Cool, huh?

imagesscreen.jpg, 33 kB

Hold on to Your Horses

In Hugin, you may notice on the Image tab a Feature Matching (Autopano). This feature uses the same. Read that again. The Same. And Again. The same SIFT technology that is used in Autostitch to find control points for use in making your image. The problem is that if you use the program in the U.S.A. there is a patent on the technology that was developed using your tax dollars that restricts Hugin from using it. You paid for it, but they get to profit from it. Go figure. Search around the Internet, and you will be able to find the file that powers this feature. I believe there is a site in France that has it available for download.

Don’t press this button yet. Or you can if you want, but I’d wait.

Setting the Lens Up – Camera and Lens Tab

This is the fun, and, for most cameras, easy part. The author of the PTLens program as spent a good amount of time solving a problem for us. Each lens has distortion, and if you remember what I said above, that if we rotate around the nodal point and had no distortions in our lens, then the images would stitch perfectly. Well, like I said, lenses have distortions, but we can set three parameters for each lens. All you have to do is look up the lens in the profile file found with PTLens. For example, here is one for the Nikkor 12-24 DX.

begin lens
group: nikonSLR
multiplier: 1.5
menu_lens: 12-24mm f/4G ED-IF AF-S DX Nikkor
cal_abc: 12 -0.016006 0.024041 0.000000
cal_abc: 13 -0.017096 0.030498 0.000000
cal_abc: 14 -0.017730 0.031719 0.000000
cal_abc: 15 -0.013174 0.027255 0.000000

cal_abc: 16 -0.009629 0.021705 0.000000
cal_abc: 17 -0.006736 0.016621 0.000000
cal_abc: 18 -0.007763 0.019343 0.000000
cal_abc: 19 -0.005218 0.014696 0.000000
cal_abc: 20 -0.005775 0.015956 0.000000
cal_abc: 22 -0.005197 0.015329 0.000000
cal_abc: 24 -0.007101 0.018378 0.000000
end

Since, we are using the lens at 12mm, we can use the cal_abc line for 12: this lists the a, b, and c parameters as -0.016006, 0.024041, 0.000000, respectively. After you find the parameters for your lens, click on the first image, and in the proper box enter the numbers you found for your lens. Make sure that the inherit box is check so that these numbers are applied to all of the images. Also, make sure to change the lens type to the type of lens you are using. For most lenses, use normal, but for the 10.5 DX use Full frame fisheye or for the Sigma 8mm use circular fisheye.

The numbers for the 10.5 DX are:

begin lens
group: nikonSLR
multiplier: 1.5
menu_lens: 10.5 DX
cal_abc: 10.5 -0.003863 -0.031091 0.016184
end

The second thing we need to do is enter the focal length of the lens and the crop factor for the lens. So, for a D70 and a 10.5 DX, we would enter 10.5 and 1.5 for focal length and crop factor, respectively. Hit enter and the program will estimate the degrees of view and the focal length at a crop factor of 1. We’ll probably adjust this later.

lensscreen.jpg, 33 kB

Image Center Shift

The image center shift is an important and required number to set to get a perfect stitch, but we are going to leave it at zero and move on. Alternatively, you can figure this out using a series of three images. When you shoot the images, make sure that you have overlap in all three images. Maybe 60% each image. Then select controls points that are in all three images, and run the optimizer on the Image Center Shift. But unless you have extra time or want to just verify that everything is perfect, you probably don’t need to worry about it. By the way, my D70 has a horizontal shift of 5.42 pixels, and a vertical shift of 6.3 pixels. Six pixels will make an apparent seam in the image if you don’t account for this. Image Shearing is similar to Image Center Shift, but it is the parameter you adjust if scanning film.

The Fun Part

Now that we’ve come this far only by entering numbers, let’s look at how well we’ve done. Open the Preview Panorama window and take a look at how you’ve done. After you say, “Cool, huh?” Save your lens using the Lens management tool. If you do this, then you’ll never have to enter the numbers again. These numbers may change slightly when we optimizer the image, so you may have to resave the lens, but they will probably stay the same.

Using Control Points

The next step is to add control points. What control points do is show the Optimizer program were in the two images selected are the points the same. I usually don’t use control points for the up and down images, so you may just want to wait to add them until after you’ve entered control points. The easiest way to do control points is to let Autopano select them. It does a very good job. After you optimize you will look at the distance between points. A higher distance suggests that you entered a control point incorrectly. If you can’t find Autopano then you’ll have to enter them yourself. Select an easy to find point in the left image and then move to the right image and find the same point. Hugin will try and match the points for you, but often fails. After you have a match you like, press the “a” button, which will add the control point to the project. To move both image screens at once you have to hold down the SHIFT key as you move your mouse. Don’t use the scroll bars, because they won’t move both images as you hold the SHIFT key. You can have Hugin fine tune each image as you add it. Or after you are finished fine tune all the points using the commands in the edit menu. By pressing the F3 Button, you can pull up a control point list, which will show you the distances between points. If you see, any big distances (over 1,) you may want to look at those and fix them.

Add, at least, three control points for each image pair. I’d say that six or ten are better. If you are using Autopano, you can select as many as you want. Since you don’t have to add any, then do 10 to 20.

controlpointscreen.jpg, 35 kB

Optimizing your Stitching Files

After you have finished with control points, you need to optimize the parameters. By doing this, you have the program figure out. Select “the Custom parameters below” from the drop down menu. Then deselect everything. The first item that we are going to Optimize is the yaw of our images. Remember we entered rough estimates earlier, but now we are going to fix this. Press the select button and then deselect image 0, which is going to become our anchor image. Hit the optimize now button. The program will run some calculations and blam, it will ask you to accept. As long as your control points were close, it should work. Then the next step is to work through the parameters selecting all the boxes except for the image 0. Some people do these separate from each other, and other do them by running one and then adding the next. Either way works well. If you are coming up with an average control point distance of over 6 or 7, you may want to go back and fix control points with big variations by looking at the Control Point Table. Select the points that have big distances and fix them by clicking on the points. You can spend a lot of time making things perfect, but 2 to 3 pixels on your final optimization run should turn out a very good panoramic.

optimizerscreen.jpg, 32 kB

Stitching Your VR Tour for Java Viewers

Now, that you’ve selected control points, optimized the image, gotten your pixels down to 2 or 3, you are ready to stitch. The first thing to try is a quick stitch. From the drop down menu, select “into a draft-quality JPEG file” “as an Equirectangular.” Then press the “Stitch Now!” button. A few seconds later a file will be ready to look at. Look it over for problems. If it looks good then it’s time to move on.

Enblend or Photoshop

There are two methods of final touch up that you will want to consider before you move on to creating a high quality image. Almost all images require some sort of final correction along the seams. Switch the Quick Stitcher setting to “with custom settings below,” and then you have to choose if you want the computer to do it or if you want to do it. If you want to do it in Photoshop or any other image-editing program, then save the image as a multilayer PSD or TIFF. If you want the computer to do the work, then select Enblend to do it. This is a separate download. You will have to tell Hugin were you put it. If you use Enblend, it looks like Hugin only supports it for its stitching engine “nona,” so select nona and check Enblend.

The next step is to calculate the Field of View. For our propose it is 360×180. Then select the final Panorama Image Size. You can have the program do it if you want. For web based java tours 2000 pixels by 1000 pixels is a good size. Select the Output File Options as described above and hit Stitch now!

That’s it. Well….

The Nadir Image

Finally, after you have produced a nice stitch that you are happy with, it is time to add the nadir point. I’m sure there are as many ways to do this, as there are nadir points, but the way I do it, is open the Panoramic picture in PT Editor. Move around the image to check it out and look for problems, and then point the viewer down and select from the Edit menu extract partial view. Name it Image.tif. You have to enter the .tif extension or it won’t open up in image-editing programs. After PT Editor does its thing, open it in your image-editing program and open the down image you took without the tripod. Then transform and scale and rotate the down image until it fits perfectly over the tripod head in the panorama extraction. After you are satisfied, save the image, and load the image using the edit menu in PT editor. Then if you are happy, Save the panorama, and do your final adjustment in Photoshop.

BTW, if you want to add a logo to the bottom of the image, you can do this using PT Editor the same way you did with adding the nadir point.

kayakbuild.jpg, 41 kB

Conclusion

Well, I don’t know how quick or dirty this stitching lesson was. It ended up with over 3,900 words and eight pages, which would have been way too big for the magazine I used to write for, but, hopefully, it is helpful. If you have questions, email me from the contact page. I will, hopefully, be able to answer the questions, and clarify it in the text of this article.

If you’ve enjoyed and learned from this article, consider supporting my business by purchasing a print from me. I appreciate your traffic, and you reading this article, and I thank you for any business that we can build together. If you need more hands on learning, I am available for panoramic workshops on the North Shore of Lake Superior. Email or Call for options.

Appendix

If you want to display these on the web as VR images, you will have to learn about PT Viewer. I suggest that you start here.


Recommended Posts
Showing 16 comments
  • Bryan
    Reply

    If anyone is wondering, I’m moving my website mainly over to my blog software, so that it’s easier for me to maintain. There will be some changes in the coming days as I have time for them.

    It’s not a high priority for me. Here is a popular article that will disappear from the old html and move into the blog.

  • Ed
    Reply

    Great site, thank you for taking the time to help us beginners out there. I have been an amateur photographer for years and recently paid attention to the panorama and the vr images, and I am completely fascinated by it. Your site was a great help for me to create the first equirectangular pano. I am still trying to figure out how to correctly stitch the nadir and zenith shots. And then I will have to figure out how to convert it to QTVR or flash. If you have the time that would be very valuable “how to” for the website. Thanks again, it is people like you who make the world a better place.
    Sincerely,
    Ed
    Chicago,IL

  • Bryan
    Reply

    Thanks, Ed. That’s a very kind compliment! I’m glad you found this helpful. It took me a long time to sort through everything to be able to figure out how to make panos. I just hope this will help more people.

    Thanks!

  • DBL
    Reply

    Too complicated and circular, just like every other stitching tutorial. (I say this as somebody who has stitched successfully and found all tutorials useless in this regard — I discovered my process by trial & error over the course of a full week.) For some reason that I don’t fully understand, people who are interested in stitching panoramas are very bad at explaining themselves clearly, and nearly every tutorial pretty much requires already having done a panorama to understand what the heck they’re talking about — which of course defeats the point.

    Three words of advice for every tutorial writer: Define. Your. Terms.

    Yes — every single one. Quick and dirty is not the answer. Long and fully backgrounded and referenced, and framed in layman’s term — *that* would be nice to see.

  • DBL
    Reply

    Okay maybe I was a little hard on this tutorial — clearly more of an effort has been made than usual to open this process to the layman. You sort of define *some* of the terms. But I still have to say that this article is still going to be very tough for anybody to understand who has not already tried to do this stuff and encountered all of these terms before.

  • Bryan
    Reply

    DBL- Thanks, for the comments. I think that if you follow the steps here, you’ll end up successfully stitching an image. Back when I had first posted this several years ago as a static html page, I received many comments about how it helped Real Estate Photographers with creating VR Tours. I even had several, as in two, phone calls thanking me for the tutorial.

    Stitching has come a long way since I first posted it, and I wrote it, basically, to help Real Estate Photographers that had a grasp on basic concept and not the layman.

    Thanks, for the comments. It sounds like you have a process and a grasp on how you would like to write a tutorial. I encourage you to write one and post a link here, so others who find my tutorial complex will be able to easily find another source.

  • DBL
    Reply

    Yeah I get it, if I think it can be written so much better, why don’t I write it myself. A very good point. But just so you know what I’m talking about, you have a full section entitled ‘The Downward Images for the 10.5 DX’ and the only way to figure out that this cypher means is to read back and find a parenthetical note that does not apply to everybody. Technical people just do this unconscious. ‘Oh yeah, the 10.5.’ The what? And what are ‘downward images’?

    And this stuff is just totally bewildering: ‘In Hugin, you may notice on the Image tab a Feature Matching (Autopano). This feature uses the same. Read that again. The Same. And Again. The same SIFT technology that is used in Autostitch to find control points for use in making your image.’ You have to read that sentence structure about five times to figure out that you are using sentences in a non-standard way. And who are you speaking to here? Why are you so emphatic? Did I argue against you? Or have other panorama experts argued against you?

    You see, you have written this subconsciously for people who already know exactly what you’re talking about. There are a lot more examples of why this tutorial is much more difficult to read than it needs to be.

    However it is still probably the best one I’ve seen because the others are all so damn abysmal. That’s why you are getting thank yous to people to whom this is like water in the desert.

    I just don’t understand why panorama people have so many difficulties imagining and writing toward a layman’s mindset — I guess they are just too deep in a very deep forest of references.

  • Bryan
    Reply

    I don’t want to beat a dead horse on this, but this wasn’t written for the layman, it was written for Real Estate Agents that had a basic understanding of the concepts. I used to do Real Estate Photography and had questions about the process. Thus this article.

    Thanks for the points and thanks for reading the tutorial.

  • DBL
    Reply

    This tutorial is not for the layman? You should have said that, up front. ‘Quick and dirty’ gives an entirely different impression. Anyway, I don’t want to beat this to death, either. If your tutorial is meant for people with already a certain level of expertise, then none of my previous criticisms apply — only the one about misleading people. I do appreciate that you have engaged with me and remained polite despite some pretty bold criticism.

  • patata
    Reply

    Great tutorial. Thanks for it.
    It has solved many of the doubts I had (still have any, :-))

  • Bryan
    Reply

    Patata – Thanks! I’m glad it helped you out. If there’s something more you don’t understand, let me know, I’m moving into my slower season, so I have a tiny touch of free time to come up with something.

  • Stacey Bindman
    Reply

    Hello Bryan,I have a Panoramic Manfrotto head and would finally like to use it!
    1. In your paragraph “Calibrate a Panoramic Tripod Head”, you said to “Put the second broom so it is hiding behind the first when you look through the viewfinder. Now rotate your tripod head” When you say rotate the tripod head, do you mean left or right, or up or down?

    2. In the paragraph “Shooting Your Pictures”, you said to I: Check that your zoom is set to the correct focal length. How do I determine the correct focal length?

    Thanking you in advance for your assistance,
    (Mr.) Stacey Bindman, Montreal (Canada)

  • Bryan
    Reply

    Hi, Stacey,

    1. Left and right.
    2. If you’re using a zoom, make sure you set it to the length that you want to shoot it at. Usually, it’s the widest length.

    Hope this helps.

  • Lukas
    Reply

    Great tutorial, thanks a lot. Just one thing: by now, PTLens saves the lens profiles in a binary .dat fomat instead of the prior .txt file. Is there any way to get the parameters out of the .dat file or do you maybe still have a profile.txt around somewhere?

    rgds
    lukas

    • Bryan
      Reply

      I don’t have a .txt file around and have no idea how to get the info out of a .dat file. Sorry. I switched from Hugins to Autopano Giga a couple of years ago for all my stitching. It’s just much much faster.

pingbacks / trackbacks

Leave a Comment

0

Start typing and press Enter to search