Creating Panoramas

Steven Dutch, Natural and Applied Sciences,University of Wisconsin - Green Bay
First-time Visitors: Please visitSite Map and Disclaimer. Use "Back" to return here.

Digital cameras and computers allow you to create nifty panoramic views, which you can post on the Web. Here's how. Below are four frames of Upheaval Dome, Utah. Obviously the frames at least have to overlap before we can make a panorama!

You need some standard imaging software (Photoshop, Paint Shop Pro, etc.) to do this. Most good packages have the same general sorts of tools.

Let's start by just naively pasting frames side by side:

We can immediately see several problems we'll need to fix here:

Decide the Overall Layout

A naive layout like the one above is not what we want, but it can be a useful starting point. Alternatively, you can open all your frames, reduce them to thumbnails, and move them about. Frames will vary in exposure, so you'll need to pick one as a standard. With panoramas the sun angle will vary considerably across the scene, affecting both color balance and exposure. I try to pick something in the mid-range of exposures that won't result in other frames getting too light or dark as I match them. In the scene above, the right-most frame has about the best exposure, plus as a bonus, the horizon is level.

Lots of things in the panorama making process can degrade the quality of images. Therefore, if you plan on using small images on the Web, do the work at a larger scale and reduce the final result.

Correcting the Horizon

Obviously, before we can do anything else with a frame, we have to straighten it out. Almost all hand-held pictures have tilted horizons. Most graphics packages allow scenes to be rotated, but, there's a price. Here we rotate the second-rightmost frame to level the horizon:

First, the frame becomes noticeably softer, a result of combining pixels during rotation. Second, the black background reveals that the edge of the frame is anti-aliased. The frame will have to be cropped before it can be joined to a neighbor.

Also, note that rotating a scene makes it bigger. The picture area is the same but the frame boundaries are larger.

The solution is simple: enlarge the frame, rotate it, then reduce it back to the original scale. The bottom frame is noticeably more crisp than the top frame. Enlarging the frame means that many of the averaged-out pixels will disappear in the final resized view.

Also, we need to pick a standard frame (in this case it's the right one). Enlarge the picture area enough to allow for inserting other frames, and draw a horizon line. A border is added here solely to show the working area.

Joining Frames

There are several reasons objects in our naive assembly don't line up between frames:

We can't entirely control the second and third factors but the fix for the first one is simple. Take successive frames with moderate overlap and join them along a line about equidistant from the edge of both frames. 

Note, by the way, that the horizon on the left frame below is not perfectly level. Most graphics packages, for reasons that make programming sense but are not very convenient to users, allow rotations only in whole degrees. Pick the rotation that fits the horizon line best.

In the frame above, the red line is about equidistant from the corresponding edge of both frames and should have the same scale. However, note that although the red line passes through the large ledge at the bottom of the frame, it passes through very different points on the horizon. What to do? There are several options:

Here there are two critical areas, the horizon and canyon rim, and the large ledge at the bottom. Neither can really tolerate a mismatch. On the other hand, a slight mismatch in the talus slope probably won't be noticed. So we can actually match the frames piecemeal.

So we pick a join line (vertical red line) that gives a good match for the horizon and rim, but one that results in quite a mismatch at the lower ledge. We can copy and paste a small snippet of the left frame (red box) to eliminate the mismatch at the ledge and put it someplace less conspicuous.

Matching Exposure

Above we have all four frames rotated as needed to fit the horizon line and joined. Note that we have perspective issues in the bottom of the scene in every case. That's geometry, and we just have to deal with it. But first, we need to deal with another issue. The frames are not all equally light, and the two on the left seem distinctly more blue than on the right.

To my taste, the frame at far right has the best overall exposure (I'd like a darker sky) . The frame to its left is a bit too light, the one left of that is darkest of all and the leftmost frame is a tad darker and maybe a bit less contrasty than the rightmost frame.

One of the most irritating things about consumer grade digital cameras is that so much is out of the user's control. In particular, they set their own exposure and color balance. Trying to match frames for brightness, contrast, and color is like trying to scratch an itch that stays just out of reach. I wish there were some simple recipe to follow, but it's largely a matter of practice.

The worst problems arise with panoramas that shoot close to the sun. It is very common in such cases to end up with the sky brighter than the adjacent frame and the foreground darker. About the only solution for such cases is to treat different parts of the frame separately.

Although the scene below shows the result of combining all four frames, don't assemble frames first and then try to match exposures. Instead, join the scene a frame at a time and match exposure before adding the next.

In the scene above, the second rightmost frame was reduced 4% in brightness. The third frame turned out to look dark only by contrast with the second frame. It was actually only a little darker than the right frame, but it was also less contrasty and bluer. Boosting contrast 7% and red and green 5% each matched it nicely. The leftmost frame needed the same color shift and a bit more contrast. Red and green were boosted 5%, contrast 9%, and brightness reduced 3%. In general increasing contrast brightens light areas and requires a bit of decrease in brightness to compensate. So even though the left frame is darker than the right frame, increasing contrast made it necessary to reduce brightness.

Within the canyon, color and brightness are matched very precisely, but the sky is not. Getting good sky matches is very hard, and unless you're documenting weather phenomena, nobody cares much where the clouds were, so we resort to touch-up tools for the final fix.

Just color the sky blue? Try it! You'll learn in a hurry that the sky is anything but a uniform shade of blue!

There's also an optical effect called vignetting that causes areas near the edge of a frame to get less light than the center. First, it's farther from the lens so light is spread out over a larger area. Second, an oblique view of the aperture is smaller than a straight-on view. Digital cameras can correct for this effect, but not perfectly.

Touching Up

There are a lot of tools available in most graphics packages for touching up images. The one to use most sparingly is the smudge tool. Real scenes have noise, which the smudge tool blurs, creating a muddy, unnaturally smooth result. Great for some artistic purposes, but not here.

On the other hand, the clone tool is immensely useful. It copies pixels form a source location to the destination. Right click on the source area, then left click to copy the pixels. It's great for filling in texture like grass, leaves, or rock, and if you set the transparency to a middle value it will merge textures and colors from the source to the destination.

Below, the clone tool was used to fill in slight gaps at the top of the scene and eliminate the sky mismatches. Don't be too slavish is copying from one area to the other or you'll get obvious repetitions of objects. Instead, click on various source areas to add an element of randomness.

We still have matching issues at the bottom of the scene. These are too big and too close together for the clone tool to work. Instead, cutting and pasting small areas from the original frames works best. 

The final result. A patch covering each mismatched area was copied from a frame and pasted. Minor edge irregularities were fixed with the clone tool. The gap in the lower right corner was also filled in with the clone tool.

Tip: if you want to be recognized as a klutz, get careless with the clone tool. Nothing screams "bad Photoshop" (regardless of what program you actually use) as much as a too obvious cloning job. If you clone an area repeatedly, you will get obvious pattern repetitions that stand out like a sore thumb. So find a number of areas with colors and textures that will work and clone randomly from each one. And make sure you don't put a cloned patch too close to the source.

Return to Computer Tips Index
Return to Professor Dutch's Home Page

Created 18 January 2002, Last Update 26 February 2010

Not an official UW Green Bay site