Creating Panorama pictures or: “The power of open source software”

First, a little disclaimer:

I am not a good photographer. All I know is that longer shutter values give more light, so does a wider aperture. That’s it.

I do not own a good camera. It even isn’t a SLR. It is so old, is sucessor already has a sucessor.

Despite these more than obvious limitations, I managed to create some decent looking shots, all with the help of the above mentioned equipment and open source software.

Cathedral in Palma de Mallorca

In particular, I am talking about:

Hugin - the panorama stitcher. To me, hugin is one of the greatest pieces of F(L)OSS to date. It builds on extremely powerfull tools which feature heavy mathematics and insanely clever algorithms that are way over my head, yet it gives me the power to use these tools to create results that leave my viewers with dropped jars. And all of this with no more than 4 dialogs, each of which as easy as browsing the web.

Gimp - Gimp probably does not need an introduction. The Title says it all: GNU Image Manipulation Program. Nothing more, nothing less. In this tutorial I will only use a very small function of Gimp’s features:

  • automatic color adjustment
  • selecting and cropping a rectangular area out of a picture and setting the selection as the new canvas
  • the incredible lomo plugin

Phatch - Photo batch processing. Although not exactly needed for panorama creation, it still makes my list of the must-have applications for image processing. It’s features include almost every common task in (mass) image processing. What makes it a killer for me is:

  • it’s power. Almost nothing you do on a lot of images that can’t be automated here
  • it’s style. Beautiful icons as well as ui. It matters
  • it’s reusability. Create a sequence of actions once and then apply them over and over again.

The Start

It starts with the pictures. This is the most important steps. If you do well here, the rest of the steps will go like clockwork. If you do badly here, the rest will be a neverending pain and the result will not be satisfying. So what are the cornerstones of a good set of pictures for a panorama?

Not too close focus. If you focus on something that is not very far away from the point you shoot, you run into a problem of perspective when stitching the photos. The result will be that your image will be far from rectangular but some sort of rainbow shape. That is why it is extremely difficuilt to shoot a panorama from, let’s say, your room. It is not impossible, only I didn’t manage it yet.

Constant camera parameters. When shooting panoramas, you shoot most parts of the scenary more than once. But if you have the camera on an automatic adjustment mode, the parameters of aperture and shutter will adjust each time you move the camera, resulting in different shots of the same area. Although Hugin has a great enblending feature that tries to adjust the images, it cannot do miracles. If you have pictures with different gamma, you will have soft edges instead of hard ones, but you will have edges and edges kill the feeling of the panorama beeing a single picture.

Constant horizon. As stupid as it may sound: This one is important! Prior to shooting your pictures, you have to think about the horizon line of your panaroama. By horizon line I mean the middle line of your picture. It should be a straight line that is parallel to the natural horizon. If you mess this up, you will loose much quality, at best.

Here are the step-by-step instructions to shooting a panroama set of pictures:

  1. Set the camera to landscape mode and let it adjust to what you think to be a median point of your scene in terms of exposure
  2. remember the values the camera chose for shutter and aperture, switch to manual mode and enter these values
  3. scan the whole scene and watch the exposure indication
  4. reflect what your shutter and aperture values mean for the resulting images. Which parts do you want to be the best exposed? Which parts can be over/under exposed?
  5. Adjust shutter and aperture. Switch back to 4. until you are satisfied
  6. shoot images with an overlap of ~30%-40% without moving. Let the autofocus of the camera adjust to every image, this does not affect the resulting exposure.

In the end your pictures could look something like this:

Stitching

Now go back to your lab and launch Hugin.

Now, Hugin is very powerful. Over at their site, there are wonderful tutorials, docu and tech explanations. So I won’t even try to get into that. I will use Hugin to do the following:

  1. Load the images
  2. Set a position and light anchor
  3. Set control points (i.e. points in the pictures that occur in more than one image). This can be done via an assistant, more about this soon.
  4. Optimize the images according to these control points
  5. Preview the output
  6. set the parameters of the resulting panorama
  7. Stitch and blend the beast

A Note about the hugin version:

The current version in the hardy repos is 0.7b4. This version works fine for me. I encounter one bug from time to time: When you resize the image preview panels in the control point area, sometimes the images vanish, leaving you with a gray widget. Don’t panic, just save your project, exit hugin and start it again.

At the time of writing, hugin version 0.7rc2 has been released. It has much more features than 0.7b4. It can do “exposure fusion” and “HDR”. I do not exactly understand what this is, and the changelog isn’t of much help to me. In fact, I never used them. Who wants to be at the bleeding edge or use those new features, there is an excellent compilation howto at the pantotools wiki. I followed the steps there and everything worked out of the box. But be prepared to install a decent pile of packages, check out several projects vom versioning systems and compile for … quite some time.

The Assistant

Hugin offers an assistant that guides you through the creation process like windows installers do. I prefer to do the manual round as I have more control about what happens and what happens when. So the Starting point for me is the files dialog:

Here we add the files involved in our panorama. Make sure the files are in the correct ordering or add them in the correct order. Then select the middle image and make it an anchor for both position and light.

Autopano

Now you are at a turning point. You can autopano make search for control points, or set them manually.

The advantages of autopano:

  • It compares every pair of input images, not just adjacent pairs. You will get alot of control points if you shot with enough overlay.
  • It finds control points where the human eye would not. Imagine you shot a forest or something like that, you are out of luck. Hugin is not. I think each image gets transformed into a (huge) set of defining points and these “graphs” are than scanned for simuliarities. This method does not fail.

The disadvantages of autopano:

  • It’s slow. This is not exaclty true. Compared to what it does, it is super fast. But what it does is really time consuming. Also, it’s time growth is O(n²) if n is the amount of pictures, as it searches every pair (I am just assuming it is like that, I do not know for sure and would be delighted to get a comment if I am wrong).
  • Its choice of points lacks human intuition. Now how can that be a disadvantage? When you set points manually, you put some brain in your choice. You choose the points carefully in order to make them good points, autopano cannot do that. It just searches for points (using whatever algorithm) until it has found as many as you told it to find and moves on.

Control Points

So what makes a control point a good control point?

  • Focus. Try to chose points that are in your focus area. I you shoot a house 20m away from you, don’t pick a TV-tower 5km into the city. If you shoot a mountain line, don’t pick a car on the parking lot you are standing on
  • Perspective. Try to chose points that are significant indicators of perspective. Edges of buildings are good. Corners of windows are good. But be aware that a point is not a point in the mathematical sense of the word (i.e. a circle with radius 0), but rather a smal area. So if you chose an edge of a house, but behind that house is another house which is 50m behind the one you chose, make sure that your point does not include the second house. If it does, you confuse the software, because if you move your camera (or even worse, yourself) the 2 points will shift differently.
  • Sufficiency. Try to chose points that cover your whole scenary. Try to chose points from the corners of the individual images and use the same point again in the next pair.

My experience is that it is not necessarily better to define many points. While control points are absolutely vital to the functionality of hugin, each control point constrains the stitching and blending tools in their ability to produce the best results. Chose 3-5 control points that match the criteria above. Do not chose control points near “critcal” areas, such as people or moving cars. These areas will look best in the outcome if the tools did not have to maintain on e of these points, but could produce the best picture.

Optimization

When you are done with your control points. It is time to lay your fate in the hands of hugin. Again, I habe no clue what is really going on under the hood, but I think the optimization step works like this:

With the defined control points, the images are “pinned” together at these points. Of course, this will not work exactly. The world is 3D, a photo 2D. So what hugin does is paint the image on the skin of an imaginary ball and adjust the parameters until the points are as close as possible. The outcome of this process is shown to you when you press “optimzie now” in the optimization panel:

These values show the distances between the control points after the optimization. You get an average, a maximum and a variance. To understand these values you have to have some basic statistic knowledge. If your average is low, but you have a high max (e.g. average = 1, max = 10) then you most probably chose one bad point. If you have a high variance, you screwed up. Generally speaking, everything under 1 is superb ( 1 think this are pixels, so everything under 1 is .. hardly existant), single points with an error < 10 can be corrected, but everything wors will not work.

After the optimization, you will see the optimized values for yaw, pitch and roll in the optimization pane. Also, If you go back to the control points, you now see the error of each point displayed. In that way, you can rework bad ones, keep good ones and optimize again.

When you are done, have a look at the preview:

Now this already looks really good. You can do alot of thing here, like adjusting viewpoints and whatsoever. I never used them so far.

Actual Stitch

Now, finally on to the Stitching pane:

Here you leave the projection as equirectangular, your stitcher is nona, enblend does your blending and you want to produce one tiff file with soft enblending enabled. Actually, I don’t know if you want to do that, but that’s what I use for this tutorial and in normal use. Push the compute angle/size buttons once and … stitch them together. The result will be one big tiff file, containing our panorama as well as some transparent space.

Gimp

Let’s open it in Gimp for processing:

Use the rectangular mask tool to mark the area of the image you want to keep. Then select Image -> reduce to selection (I am just guessing the englisch names here). You could also ctrl-x and insert as new image, but that would mean gimp has to move your selection to the clipboard and then create a new file with about the same size as our tiff. If the panorama is large, this uses alot of time and space if it not locks up your PC (depending on RAM, of course). So the cropped image should look something like this:

The next step is magic to me. My camera is not very good at capturing to real colors, a SLR camera does this much better and the images get not imporved very much by this step, but with my images this is a massive improvement. Open colors -> values. This brings up a dialog where you can adjust the range of the values for colors. It has an “automatic” button which pricudes very good results on images shot with my camera. If your camera is already good, you won’t see so much improvement here. In this dialog you can also generally lighten or darken your image. Beneath the historgram are 2 triangles. They represent the dark and light end of the scheme. If you move one of them all colors will be lighten up (or darkened).

Now it is time to save the image, because the stuf I do afterwards is of questionable taste and sometimes makes the images look fake. Usually I overwrite the tiff image produced by hugin because I see no point in maintaining the huge and bulky image.

Next is the lomo filter. In the comments of the page it describes lomo:

“Technically, this plugin creates a vignetting effect, it darkens the edges and brightens the center, while increasing the contrast of the image.”

One has to understand this in order to predict the effect of this filter. The center will be lighter, the edges will be darker. The contrast will be higher. What this means is that eg the clouds in the sky will vanish, if the focus of your image is not in the center (like when doing a groupfoto), the people on the border will become darker. You have 2 ways to influence how the plugin works. You can select the area it shall be applied to and you can adjust the 3 parameters of the plugin. You can find the filter at “Filter -> Light and shadow -> lomo”, once you copied the scm file to ~/.gimp-2.4/scripts/ and restarted gimp.

To apply the filter just to one area, simply use the various selection tools to select the area of your choice and run the filter. You have to bear in mind that the current selection will act as the total image for lomo. So if you select only your center area, lomo will treat this as a full canvas and make the border of it darker and the center lighter. As for the filter options:

Vignetting softness indicates how soft the vignette will be. If you wish a higher concentration in the centre, chose a higher value. A lower value will treat the whole area more equally.

Saturation is the general strength of the filter. Adjust to fit your level.

Contrast is the level of differences the filter will create.

As a rule of thumb: If you want a softer effect increase the softness and lower both the saturation and contrast (I always have the same values for saturation and contrast as changing only one does not have much impact). This is our sample images after lomo:

To describe the effect with my own words: it looks like a grey fog has been pulled off the image. On the downside, the sky looks now almost entirely white, creating a non-realistic scenary. So let’s do it again without the sky. To do so, select the sky with the wand and invert the selection and repeat the filter.

Now the sky looks the same as before and the foreground has been “enhanced”.

Phatch

There is not much value in editing one single photo with a batch processor and the focus of this tutorial really is the panorama stuff, so I will not get dirty with phatch right here. There is a great tutorial in their wiki to get started.

Closing notes

As you may have noticed during reading, I am not an expert in any of the domains covered here. I just wanted to share my personal experience and learning curve with anyone interested. That beeing said, it directly follows that I have made many mistakes througout the tutorial. If you spot one, please leave a comment. Thank you.

The process described above is just one (pretty standard) way to process your pictures. There are countless variations. Hugin alone offers dozen. You can play with viewpoints or the new blending methods if you dare to compile 0.7rc2 (which you should). Just one example that has happened quite a few times to me.

The Problem: You have a person, car or other moving object on your series of shots which is in different states in different pictures. You can try to leave as much power to hugin by not setting control points near the area, and very often hugin succeeds in sorting out which one to take and which one to overwrite. But sometimes you will not be satisfied. Or the same usecase: You have something/someone in one photo but not in the other and hugin keeps deleting it.

The solution: Order hugin to make not one tiff, but a multilayered tiff. This will result in an even larger file, but if you open it with gimp every of your input images will be fully intact (with the transformations done by hugin) and stored in one dedicated layer. What you can do now is erase an area in one layer to let the one below shine through. Feel free to exploit all the power of gimps tools.

Tags: ,

12 Antworten zu “Creating Panorama pictures or: “The power of open source software””

  1. Creating Panorama pictures or: “The power of open source software” sagt:

    [...] Original post by admin [...]

  2. Nico sagt:

    I have started playing with Hugin recently too.

    I have a few 360 panos here:

    http://www.youplala.net/tag/panorama

    DSLR, but a normal tripod without pano head.

    Nico

  3. Bastian sagt:

    really neat pictures nico! especially catching the waves on a 360. I don’t know if there were any news in my post for a pro like you, but thanks for your link to your pictures!

    Bastian

  4. Recent Faves Tagged With "compute" : MyNetFaves sagt:

    [...] public links >> compute Creating Panorama pictures or: “The power of open source… First saved by nggron | 1 days ago It Does Not Compute… Danger, Will Robinson!! It Does Not [...]

  5. Recent Links Tagged With "panoramas" - JabberTags sagt:

    [...] Wed 03-12-2008 Automatic panoramas with hugin and autopano Saved by gyuri69 on Mon 01-12-2008 Creating Panorama pictures or: “The power of open source software” Saved by dansage on Thu 20-11-2008 Lake Powell Panoramas Saved by absa on Wed 19-11-2008 Create [...]

  6. AlexanderGreat sagt:

    hey…

    Great job. But not enought info. Where can i read more?…

  7. AlexanderGreat sagt:

    hello…

    wonderful…

  8. liger sagt:

    hello…

    You need more rest i think…

  9. Bookmarks about Growth sagt:

    [...] - bookmarked by 1 members originally found by mavacheroba on 2009-02-25 Creating Panorama pictures or: “The power of open source… http://blog.simpsus.de/?p=10 - bookmarked by 6 members originally found by hanshenderson on [...]

  10. Websites tagged "wors" on Postsaver sagt:

    [...] Worship saved by MarinaWolf2009-03-15 - my wors is better then yours saved by boltman2009-03-14 - Creating Panorama pictures or: “The power of open source… saved by b0risj2009-03-07 - Apple Picking in the Rain saved by Hybernaut2009-03-07 - Social [...]

  11. KonstantinMiller sagt:

    I have been looking looking around for this kind of information. Will you post some more in future? I’ll be grateful if you will.

  12. admin sagt:

    @Konstantin: In fact there has been some development in the tools! Hugin has increased a lot, I discovered some new features and the whole toolset is now able to handle not only panoramas, but HDRs as well. So, what is your main topic of interest? Perhaps I can hack some info together on it…

Hinterlasse eine Antwort