Guide to DSLR night sky imaging: part 2

In part 1 of the guide, I showed you the most basic techniques of bringing up the beauty of the night sky through DSLR imaging. There wasn’t much to it besides knowing well the camera and a few tricks. That technique can render some pretty satisfying pictures, especially if you are on a dark place with a beautiful foreground landscape. However, when there is light pollution, Moon illumination or if you want to portrait extremely faint objects (such as the disk of the Andromeda Galaxy or the Magellanic clouds), you will have to gather more light.

But how to do that? Well, through the three ways I stated previously: rising the sensitivity of the sensor, reaching larger apertures and getting longer exposure times. Astronomers try to augment their aperture by using larger and larger telescopes, but if we are only armed with a camera, there is not much to do in that front. However, we can try using a higher ISO and longer exposure times. But that comes with a cost: besides light, a lot of junk (noise, sky glow, star trails, vignetting) will pile up in the picture and make them not as pretty as we imagined. Well, what then? We need to change the basic technique in order to get rid of the junk. Also, in these advanced techniques, you’ll spend a much longer time doing post-processing than actually taking the pictures, so be prepared for that. And do not give up!

As always, I still consider myself a beginner, suggestions to this guide are always welcome, and I will keep this post updated from time to time.

Equipment and software needed

Most of the equipment is the same as the ones from part 1. But in addition to them, here I list the software needed for image editing. Keep in mind that the prices I list here are for new, entry-level devices, and are also approximate.

  • DSLR camera + stock lenses: € 300 or US$ 375.
  • Class 10 SD card: around € 50. Get the higher class you can! Otherwise you’ll suffer from slow data-writing.
  • A tripod: starting from € 50.
  • Your best computer: depending on the number of pixels your camera takes, dealing with various layers of images will take a HUGE toll on your computer’s processing power.
  • An image editor program: I recommend GIMP, along with the plugin G’MIC and a plugin that can read raw images from your camera model (I use UFRaw); Nikon users can try their official image editor Capture NX, but it is so crazy expensive, it’s not even funny.

The following items are optional, but strongly recommended:

  • Remote controller compatible with your camera: starting from US$ 35, I think. I got this one for my Nikon D3100.
  • A very homogeneous (preferably white) surface.
  • A cover for the eyepiece of the camera: it usually comes stock, but it’s easy to lose it if you’re not careful.
  • Canon users can try many camera controlling software, such as APT (€ 12.70, but I heard it’s completely functional in the trial version), BackyardEOS ($ 50) or Nebulosity ($ 80). Unfortunately, Nikon users don’t have many options on that front. But the company that makes BackyardEOS is working on a BackyardNIKON program. Also, the software IRIS (free) supposedly works with some Nikon cameras, but I haven’t been successful with it.
  • The free software imageMagick to do some heavy duty work on the command line

It’s time to go raw!

Now that you are well experienced with your camera, it’s about time to do away with the training wheels. You see, DSLR cameras have a software inside them that already do some post-processing in the images, by default. For instance, here in my Nikon D3100, there are the following “auto-tweaks” that it can do: image quality, auto white balance, auto-focus, Active D-lighting, picture control, auto ISO, auto distortion control, noise reduction, and a bunch of pre-built shooting modes (landscape, portrait, macro, kids, night mode etc.) Those things are helpful if you’re just beginning, but they get in the way of night sky imaging.

The first thing to change is the image quality: go from “fine” to “raw”. The main reason is that pictures taken on fine mode are compressed (that’s why you get a JPEG file out of it), and when you compress a file, you lose information. And this is a problem if we are trying to extract the details of an image! But there are some caveats to raw files too: they are much bigger (~11 MB) compared to the JPEG ones (~6.5 MB), which also means they will quickly fill the buffer of the camera (for a Nikon D3100, it happens about 12 consecutive shoots on burst mode). Raw files are also trickier to open, because they are usually proprietary (for instance, Nikon raw images are in format NEF). There are a lot of other details on the raw vs. JPEG dichotomy, so I suggest you read on the internet about it. But, for astrophotography purposes, once you go raw, there is no turning back.

Additionally, I propose that you set every “auto” option to off or manual, along with the shooting mode (usually indicated by the letter M on the dial). There are some things that you can correct later, in the post-processing, such as the white balance, but most of them are not that easy to change after you take the picture. Also, I believe that setting the color range to Adobe RGB can render better results, but I’m not sure about that, and I think it can be changed at post-processing. Metering shouldn’t matter for our purposes.

The first thing you’ll notice when you go raw and set every auto option to off or manual, is that the photos will look like crap at first. That’s completely normal. It will be your job to make them beautiful. And in the following sections, I will show you some tricks that astronomers developed in order to do an upgrade in the quality of raw images.


Besides using these more “spartan” settings I recommended, there is not much more than what I wrote in part 1. You focus the camera using a far away source of light, and try not to shake the it. However, since you’re going to use longer exposures to gather more light, you’ll have to break down the exposures in small chunks if you don’t want get to get star trails, and then later stack these images. And depending on the mode you stack them, it can also help getting rid of the noise (more on that later). So, in this part, it’s even more recommended to have a remote controller (either a hardware or software that connects to the camera). If you don’t have a tracking mount, I recommend not going over 15 seconds, otherwise the star trails will be very prominent. Some backyard telescopes have a screw that you can attach your camera to, and if it has a tracking mount, it can work well even if the scope is not perfectly aligned. On this case, you can try 1-minute long exposures (or more if the alignment is good – but be aware of the foreground, if any). I also recommend using a cover on the eyepiece of the camera, because very little amounts of stray light can enter through there, sometimes.

Remote controllers usually have 3 timings: a delay, an exposure time and an interval. The delay is the time to begin the shooting session (it really doesn’t matter that much), while the interval is, generally, the amount of time after the shutter opens. So, for instance, if you are taking 10 second exposures, a good option for interval is 11 or 12 seconds (the shutter will open again 1 or 2 seconds after it closes). You can also decide the number of shoots to get. And if this is your first time, I recommend not going over 10 pictures, otherwise the post-processing will be extremely long, frustrating and you might get discouraged: start small and with an easy target, such as constellations or open clusters.

Regarding the ISO, you’ll have to find a balance between the amount of light that you want to get and the amount of post-processing. If you use a higher ISO (such as 1600 or 3200), you’ll certainly pick up brighter objects, but it will also produce more noise and sky glow, especially if light pollution is present. And getting rid of these is not an easy task. It’s up to you. Remember to start small.

Okay, now that we are done with the shooting, it’s important to know what kind of things there are in the photos: bias + “dark current”, vignetting, noise, sky glow, and a more general lack of colors/contrast. And from my experience, the most effective order of getting rid of these junk is the one I used to list them.

Dark frames

Dark frames are pictures used to eliminate the bias and what is called dark current. These are artificial signals that CCDs themselves produce, and they show up in the raw images. Modern cameras have very low dark current, but it’s a good measure to avoid it. Dark frames should be taken in similar conditions (mainly temperature) and settings (ISO, exposure time etc.) that you took the pictures in the first place, but instead you have to use a cover on the lenses (and on the eyepiece), because you don’t want any stray light getting into the dark frames. Take a bunch of them, something between 10 and 20. In professional level CCDs used in telescopes, usually there is no need to take dark frames, but astronomers take bias pictures, which consist of almost instantaneous exposures of the CCD when the telescope dome is closed, so they can register its bias and then eliminate them.


Flats are pictures used to determine how different parts of the CCD reacts to light, and thus will help us eliminate (or at least alleviate) distortions and vignetting (that dark border around pictures with long exposures, even thought they can be a bit “stylish” at times). There are two ways to take flats: using the sky or homogeneous surfaces. I use the back of a conference tag, because it is very white and beautifully homogeneous (it’s made of some kind of plastic).

The idea is to illuminate a surface very homogeneously so that you are sure each pixel of the CCD is receiving the same amount of light. What I do is to put my conference tag under the afternoon sunlight, be careful to not cast a shadow over it, use the highest zoom and take another bunch of pictures (again, something between 10 and 20 shoots). The exposure time should be very short, since it’s a well lit environment, and I recommend using the lowest ISO possible. If you use a high ISO, you will need to subtract dark frames from the flats (and this is another separate bunch of dark frames under the settings you used for the flats), so if you want to minimize post-processing time, use low ISO – which is not that big of a problem, if there is a lot of light.

Since we took (or are going to take) pictures of the night sky with large apertures, we should take the flats with the highest aperture possible, and also avoiding saturation. This is important because small apertures and a bright environment will highlight the dust specks inside the camera. They usually do not appear on night sky, large aperture pictures though, so you don’t want to bother with them (unless they are illuminated by stray light, and if that happens, you’re in quite a post-processing pickle). A raw flat image should look like this:


Flat taken on a white homogeneous surface under afternoon sunlight. Exp. time 1/4000 s, aperture F7.1, ISO 100, focal length 55 mm.


And we are finally here. The first thing you should is to make sure that your computer can take a hit and not overheat: go to a cool place, and do not use a notebook on your lap or on soft places. The main purpose of post-processing now is to do the data reduction, which is pretty regular task for astronomers, so much that there is an entire graduate-level course on data reduction if you take an academic path to astronomy. The idea is that you should perform the following operation: C = (R-D)/IG (1), where R a raw image (which we open as a layer), D is the dark frame master (removes unwanted noise), G is the inverse gain frame (corrects distortions) and C is the corrected layer (what we actually want). In the end, we stack all the corrected layers and get a final image!

Now that we’ve got that out of the way, it’s time to get the median of the dark frames. On GIMP, you can use the plugin G’MIC to do that (Filters > G’MIC… > Layers > Blend [median]), and be aware that you’ll have to open all the dark frame pictures as layers to do that. Also, please keep in mind that doing this will take a long computation time – if there are 10 layers with 4k resolution, it can take a few minutes, depending on how fast is your processor. Do not panic if the computer hiccups at times, it’s normal. You can also get a median by using the program imageMagick, which can be used on a command line. But, from my experience, it couldn’t deal properly with raw images, so I stuck with G’MIC. The median should produce a single image, and this is going to be the dark frame master (hereafter D) for this night sky shooting session (remember that different darks should be used for different camera settings!) You can export it as a lossless format, such as PNG or JPEG with a low level of compression. Or you can just keep it open as a layer on GIMP so you can work with it later, without losing information.

Okay, now that we have the dark frame for the night sky, it’s time to get the flat master. It is as straightforward as the dark: just take the median out of all the flats you got. If you want to keep working on GIMP, make the dark frame master invisible, and take the median of the visible layers (which contain the flats) with G’MIC. We must now normalize the flat master: that means that the pixels will be assigned with a number between 0 and 1, depending on how bright it is. This is done by dividing the image by the mean value of itself. For our purposes, this can be done by using the Color Picker Tool on GIMP: check the option Sample average, and use the maximum radius (should be 300). Now click on the brightest regions of the flat master (should be around the center). Now, that value is stored in the background color. Create a new layer, the same size as the flat master and, on Layer Fill Type, select background color. You will now have a homogeneous layer containing the mean of the flat master. Go to the layer options and change it to mode Divide instead of Normal. Merge down this layer with the flat master and you should now have a similar image to the flat, but it is now normalized. Let’s call it the inverse gain frame (hereafter IG). Thi s is because this frame represents the way the CCD register light when exposed to a homogeneous surface, and to reduce the data from our night sky images, we want to correct for it by introducing a gain at the darkest regions. In our case, we will have to divide by the inverse gain frame, hence the name.

How an inverse gain frame should look like

Now that we are done with getting the correction layers, it’s time to use them. We start by opening all (or as many as your computer can manage) night sky raw photos as layers (hereafter R_n). As equation (1) says, we need to subtract D from each R_n. You can do that by setting D from mode Normal to Subtract, duplicating D various times and move them around so that you have one D above each R_n. Make all layers invisible, and start working on each pair of D and R_n. Make a pair visible, merge D down to R_n, and repeat the process until all pairs are merged. You will now have various layers R_n-D. The next step is to correct with the gain: set IG from mode Normal to Divide, and do the same process as you did for D, for each R_n-D (multiplicate IG, merge down to each R_n-D). You should have now various corrected layers, hereafter C_n.

Aligning and stacking the frames

The next step is to align each C_n to the first layer. We already have all C_n open as layers, so let’s start from there. I think the easiest way to do the alignment is to set every layer (except for the first) from mode Normal to Screen, turn them invisible (except for the first and the one you want to align). You will see that the Screen’ed image will be kind of transparent over the first layer, and that should help you do the alignment using the Move Tool (assuming you’re on GIMP). After aligning a C_n, return it from mode Screen to Normal, make it invisible and go to another C_n, until all of them are aligned.

Now for the stacking: I think there are two different ways to do that, and I’ve seen astronomers using both ways in professional work. You can either add each layer to each other or extract the median of the set of layers.

  • Adding the layers:
    • Pros:
      • It’s faster and lighter on your computer processor
      • It will give a little bit more oomph to the faintest objects of the sky
    • Cons:
      • It will probably be noisier than the median technique
  • Extracting the median of the layers:
    • Pros:
      • It will help attenuate the noise
    • Cons:
      • It is heavy on the processor, especially if the resolution of pictures is high
      • You will need to install an add-on, because I don’t think there is a built-in median tool on GIMP
      • Median can make fainter objects disappear…?

When working on the following Comet Lovejoy image, I preferred to use a simple addition of layers, because the median extractions I was using were making the fainter objects disappear, but I’m not sure that should happen in theory. Maybe the programs I used (G’MIC and imageMagick) use some kind of “approximate median” script instead of actual statistical median? Again, I’m not sure. I suggest you to just try things out until you get a satisfying result. Notice that we haven’t, so far, dealt with the curves or levels, and you shouldn’t change them before doing the stacking, otherwise it will screw up the skyglow removal (if any). Again: do not change curves, levels or contrast before you do the stacking, unless you really know what you’re doing. GIMP cannot go too far behind with ctrl+z, so chances are you might not be able to recover from it.

Full picture of Comet Lovejoy in the constellation of Taurus, on Jan. 12, 2015, from my backyard. This is a 14×10 s of exposure, on ISO 800 and focal length 55 mm. Click to embiggen. The bright feature is a stupid wall from a nearby house.

After doing the stacking, there will be a framing effect on the product image. This is caused because you moved some of the layers around, so they sum up to different values. My solution to that is just cropping the image. Make sure that you do not crop a beautiful star cluster or a nebula, though.

Removing the skyglow and final enhancements

This part shouldn’t be too stressful if you have already gone through the previous parts. Sky glow is mainly caused by moonlight and light pollution, and removing it from the picture can help highlight the fainter objects. What I do is similar to what astronomers do with professional sky images: subtract the average value of the sky from them. The average value can be obtained the same way we did with the mean of the flat master: use the Color Pick tool and create a homogeneous layer with that value, and then merge it down on mode Subtract. That should get rid of the skyglow. You can also try to remove it by adjusting the curves. If you’re in a light polluted place, chances are your stacked image will be very red. If you’re under moonlight, it will probably be very blue. Both these conditions can be attenuated by changing levels and curves. One thing that always helps to highlight faint objects is adjusting the contrast, also on curves and levels.

Additionally, chances are the flats helped get rid of most of vignetting, but not all of it. I could not get a perfect correction for my Comet Lovejoy picture, and I tried very hard. But there is nothing that a little bit of cropping can’t do, and that is why we have 4k pixel cameras, right? So we have plenty of room to crop around.

Anyway, I think that does it. This is not an extremely detailed guide, but I think it should be helpful to people who have already started with night sky imaging. Remember that getting a perfect picture, like the ones worth an APOD, is a very daunting task. It can take many nights, several hours of post-processing, years of practice and a generous amount of luck. In fact, one of my dreams is getting a pic on APOD. But there is still a lot of ground to cover. I hope this guide can be useful to you.

Clear skies, and never give up!



Featured image: the comet C/2012 Q2 Lovejoy, taken on Jan. 12, 2015, under heavy light pollution.

Guide to DSLR night sky imaging: part 2

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