Image stacking for nightscape photography

Amateur astronomy and photography are among my many weekend passions. I recently decided to try my hand at nightscape astrophotography. It is a real challenge to do something interesting with astrophotography on a low budget. I fortunately stumbled onto an image processing technique known as “stacking,” which can produce high-quality images from an entry-level camera. Stacking is the process of aligning multiple images and adding them together. After stacking, the dynamic range is greatly improved, background noise is reduced, and faint objects become visible. There are many who believe digital post-processing is a form of cheating; obviously I am not in that camp.

In this post, I describe the methods I used to capture some nice starscapes using my Canon Digital Rebel XT SLR. I’ll start with some example images. Scroll down to see further details on how I produces these pictures.

Nightscape with image stacking

Nightscape image after stacking four frames, just after sunset. Details: Canon Digital Rebel XT, 24-second exposure, ISO 1600, f/3.5, 18mm zoom lens (bundled with camera). Sky and land stacked separately, then overlaid. Hot pixels were not removed and are clearly visible in the lower portion. Hot pixels appear as faint streaks in the upper portion due to the rotation of frames during stacking.

Milky way at Arches National Park

Image of the Milky Way, taken at Arches National Park at 1am on May 28, 2012. Four images are included in the stack, and hot pixels are masked out. The sky and land are stacked separately and overlaid. Details: ISO 1600, 44 second exposure, f/3.5, 28mm wide-angle lens on Canon Digital Rebel XT.

The basic setup

For successful nightscape/starscape photography, you the following minimal components are required:

  • A camera that can be externally triggered, that supports long “bulb” exposures. I recommend using a digital SLR such as the  Canon EOS series. These cameras span a wide range of prices. I use a Digital Rebel XT, which can be obtained used for $300-$400. Obviously, a more expensive camera will produce better results.
  • A good tripod with very low vibration. I use this model from Parks Optical, but a less-expensive option would likely suffice. The main point is to use something that doesn’t wobble in the wind.
  • Something to trigger your camera for timed exposures. There are some official camera timers, like these Canon controllers, but I find that they are highly expensive and don’t offer ideal features for night photography. I created my own controller using an Arduino board from my local Radio Shack. The details of my Arduino design are described later in this post.

With these items, you can capture some interesting nightscape photos. The quality of those photos will vary depending on camera quality, but in many cases you can compensate for a low-end camera by using image stacking, which is discussed later in this post.

ISO, exposure time and focusing in the dark

Use the fastest ISO available. Use the widest aperture possible. There is some debate about aperture and ISO for nightscapes. If you are doing a cityscape, or trying primarily to capture a terrestrial foreground subject, then you might want to consider a slower ISO and/or narrower aperture as these could create sharper images (with very long exposure time). For capturing stars, though, you want the exposure time to be as brief as possible. A fast ISO achieves this. The tradeoff is that we have to do some post-processing to eliminate the noise. The post-processing is fairly involved and can be time-consuming, but I think it is worthwhile.

The exposure time can be tricky with nightscapes. If you want to minimize the “star trail” effect, you should probably not exceed 35 seconds. In the two example images above, the first image uses a 24-second exposure, and is quite clear and sharp. The second image uses a 44-second exposure, which results in some streaking in the stars. In order to experiment with exposure times, I programmed my camera controller to step through a sequence of exposure times so that I could get the best result. The controller could be programmed, for instance, to take five frames each at 20 seconds, 25 seconds, 30 seconds, etc. I can browse through the images after shooting and determine which exposure times worked best. To me, this is the key advantage of using a programmable device like the Arduino.

To produce the best results, multiple exposures can be combined using various processing techniques, such as those describe by Luis Argerich in this post. If you are going to stack, mask and overlay several images, you may want to consider capturing a set of very long exposures that bring out the details in the foreground landscape. Depending on how much light is available, you may need several minutes to capture details in the landscape. You might also consider using a tighter aperture for the landscape — I have done landscape exposures as long as 30 minutes to get a sharp, bright image at night. You can “cut out” the landscape portion and superimpose it on top of the star field image to get the best of both domains.

Focusing is probably the toughest aspect of night photography. The problem is simply that you can’t see anything. My lens has a mark that labels infinity focus. I line in up to that mark and hope for the best. In some cases, there may be a terrestrial light that you can focus on. Some people also suggest using a laser pointer or a spot light to aid with focusing prior to starting your exposure. I’ve tried several of these methods, but the “infinity” mark still yields the best results for me.

Image processing: stacking, masking and the final composition

Starfield images are captured at high ISO, which makes them noisy. Stacking reduces the noise and brings out faint detail. In my first example image above, you can identify features as faint as 9th magnitude, much better than the naked eye under optimal conditions. In capturing these faint details, the Earth’s rotation creates the main challenge. In each of my 24-second exposures, the stars appear in slightly different positions within the frame. In order to stack the frames, they have to first be rotated and shifted into perfect alignment.

In my photos, I used Keith’s Image Stacker to handle the rotation, alignment and stacking. Keith’s tool is quite capable, but is a little non-intuitive. If you are   comfortable as a hacker, you can probably make sense out of Keith’s tool and use it fruitfully. Here are some of the key things the stacking tool can do:

  • Hot-pixel removal. “Hot pixels” are points in the camera image that are “stuck”. If you look carefully at the landscape portion of my first example, you can see some bright-red spots. These are hot pixels that I could have removed with Keith’s Image Stacker, but I left them alone in that example. To remove these points, you first need to take a long dark-frame exposure with your camera (e.g. 30 seconds with the lens cap on). Then load this as a “dark field” or “hot pixel mask.” Do this before anything else.
  • Rotation and alignment. The tool allows for automatic and manual rotation and translational shifting of your frames. Note that as you rotate the stars into alignment, the landscape becomes misaligned. This is why masking and overlays are mandatory when stacking star fields. In my examples, I performed two phases of stacking, for the stars and landscape separately.
  • Stacking. All the images are added together. The tool exports at PICT image with 32 bits per RGB channel. You need another program to convert these back to JPG (I used iPhoto).

After stacking is finished, you probably have a beautiful star field with a blurry, ugly landscape. To fix this, the only real option is to layer a clear landscape image over top of the star field. This can be done in Photoshop. I use The Gimp. The procedure is: (1) Load the stacked image as a background. (2) Load the landscape image into a new layer. (3) Carefully erase everything above the landscape, revealing the star field beneath. This process can be trickier than it sounds, since the stacking process may “smear” the landscape edge into the sky. I usually “feather” the landscape portion into the sky. For this to work, it is crucial to match the color and lighting conditions of the foreground and background layers. If the layers are not matched, the boundary may be quite conspicuous. It is also a good idea to mask hot pixels in the foreground image as they will be quite apparent (see the first example photo above).

Controlling the camera

This discussion is all just theoretical unless you have something to control long camera exposures. When I decided to start dabbling in nightscapes, I simply drove over to Radio Shack and picked up an Arduino and some additional parts, and I was shooting that same evening. If you are not already experienced with DIY electronics and programming, it may take a bit longer to get it right. In this post I give a minimal overview, but I am happy to provide further assistance to anyone who is interested.

Here is a basic description of my design. The minimal parts are:

The Arduino’s GPIO pins can source enough current to directly drive the relay’s control pin. To get a minimal working camera controller, you only need to wire the relay connections to the 2.5mm stereo jack terminals. Timing can be controlled by the Arduino using the delay() function.

Of course I decided to add some sophistication to my controller design. In the most recent iteration, I added an Adafruit LCD display with input buttons to allow fine control of timer functions in the field. My interface now allows the following features:

  • Control exposure time and time to wait between exposures (e.g. for time lapse).
  • Increment exposure time, e.g. do exposure times at 10s, then 15s, then 20s, etc.
  • Uses the Time library for more refined timing control. This also allows the device to respond to buttons and other events during the delay intervals.

Here it is:

camera controller

My Arduino camera controller.

In order to emphasize my Geek heritage, I put a decal on the back to make it look like Ziggy from Quantum Leap:


It looks like Ziggy.


3 thoughts on “Image stacking for nightscape photography

  1. Pingback: Getting Started with Night Photography | Chris Winstead

  2. Pingback: Getting Started with Night Photography | Fair Coin Toss

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s