Chapter 1, Gathering and Preparing Image Data


You may have heard the old computer data processing adage -- garbage in, garbage out. It basically means that in order to get a good result, you have to start with good data. The same principle applies to CCD images. No matter how many processing tricks you learn, the better the raw data you start with is, the better the final result will be. To start this tutorial off, I'll cover some fundamental things you need to do to insure that you have good data to process and make a final image out of.
This tutorial assumes you know the basics of operating your camera and telescope system -- that you can get the camera hooked up to the scope and computer, get everything working, and take images with the camera and save them to your computer's hard disk. If you aren't well-versed in the operation of your hardware yet, go back and read the camera's manual (and telescope system, if need be), get some time in using your equipment, and when you have the basics of operating it all down then come back here.
There are really only four things that can make the difference between a good and a bad image -- and most of them you have control over as an imager.
First, the telescope and mount combination must track well during the exposure time of each individual image. To quantify "track well," you can use the arc seconds per pixel value that you get with your particular telescope/CCD camera combination (see this link to calculate it)...for example, I get 1.07 arc seconds per pixel using my Vixen VC200L scope at f/6.4 and my StarlightXpress HX916 camera. Double that number -- in this case, 2.14 arc-seconds -- and that's how well the scope needs to track to produce a good image. Of course it's better if the tracking is at or below the arc seconds per pixel value -- you'll have a better looking, sharper, more detailed image. But double the scope resolution is the worst allowable. You can get better tracking by insuring dead-on polar alignment (see here for instructions on polar aligning). You can get better tracking by not over-burdening your mount, and insuring it's properly balanced. You can do some mechanical adjustments on the mount if it needs them, or use PEC (periodic-error correction) if the mount has that capability. And you can use a guider of some sort (seperate guider through a guide scope, on-CCD-chip guiding, or even manual guiding through a guidescope or off-axis guider). Other than the raw mechanics of your mount, which are usually still modifiable, you -- the imager -- have a great deal of control over how well your mount and scope track during an exposure. If you've done all you can with your equipment and you still get some trailing in the image due to poor tracking, it's possible to remove some trailing artifacts later on in processing (see Chapter 4, Dealing with Imperfections and Artifacts). However, it's certainly best to not *have* to try and process out tracking problems later, so do the best you can when capturing the data to begin with!

Second, the scope has to be well focused. Other than mounts that can't track well (or are poorly aligned), focus is, in my opinion, the part of imaging over which you have the most control. It's also the part that is most often overlooked or skimped on by a large number of amateur imagers! It *may* be possible to process out some slight mis-focus later on through deconvolution (see Chapter 4), but a few extra minutes spent critically focusing your telescope when starting an imaging session can save you hours or processing and great amounts of frustration (when you decide to throw out a whole night's work because it's out of focus). Take the time to focus accurately and critically, and your images will benefit greatly. Here is a page outlining some focus techniques to help speed up accurate focusing, and some tips that could help you focus better.



Hours spent imaging wasted, because the image was out of focus (on the left). With more time and attention spent on focus (on the right), a much better image is possible!

Third, each individual image -- even if they are intended to be part of a summed or averaged "stack" later -- must have adequate signal. Adequate is easy to define, but might take some experimentation to achieve...it's simply enough signal in the image so that the object you're imaging commits enough photons to the CCD to stand out from the sky background plus any noise. Some objects are easy to get lots of signal from -- M42, for instance (the Great Orion Nebula), will look good on pretty much any decent CCD camera through pretty much any scope with 30 seconds of exposure time, even from a light-polluted location. Dim objects like small galaxies sometimes don't show adequate signal with a 30 MINUTE exposure time! A few tips for increasing signal:
-- Longer! As long as the sky background isn't saturated, signal will build with increasing exposure time. If your mount/guiding setup is capable of longer exposures without tracking problems, go long!
-- Filter! At a light polluted site, an H-Alpha, OIII, or even regular red filter will cut background and let signal through.
-- Faster! Use a focal reducer if your scope takes one, to get a faster focal ratio. An SCT at f/6.3 will gather more than twice as many photons in the same time period as one at f/10 -- boosting signal.


The image on the left of the California Nebula doesn't have enough signal. Even if you stacked 100 of these images, the result would be poor! On the left was 30 seconds exposure at f/4.5 through an H-Alpha filter. On the right, increasing the exposure time 4 times to 2 minutes gives a much better result! This image has enough signal for the object to stand out from the background, and stacking multiple frames with this much signal will give a very nice result and plenty of data to work with.


Fourth and finally, seeing and sky conditions make a big difference in image quality. You may think this is something you don't have control over -- but you'd be wrong! Assess the seeing conditions when you go out to image. If the stars are jumping all over the place, don't even try to make good images that night! Practice guiding, or trying new hardware, or other techniques...but don't try to force a good image out of bad conditions. There will be other nights, though sometimes it may seem that they're few and far between! You should also try to image with as little light pollution as possible. Once again, even urban imagers have some control over this seemingly uncontrollable variable...if you have a lot of light pollution, use narrow band filters (see above) or a light pollution filter to cut back on the skyglow. Try imaging after midnight and early in the morning rather than in the evening -- many businesses turn their lights off after midnight, and there are many fewer cars on the road, so even urban sites get darker in the early morning hours.

Plan out your imaging session ahead of time, and know what you want to accomplish. Figure out how long of an exposure you can do that will give adequate signal without saturating the background or bright stars, and then how many of those you want to add/stack together for the final image. Pick your targets based on the focal length and imaging field of view of your setup -- a good image will show the object of interest as large as possible in the frame, excluding non-interesting parts or large areas of sparse sky and few stars. Wide-field images are easier to do (tracking is less critical due to high arc second per pixel values), but if the main object you're interested in showing only takes up a tiny spot in the center of the frame, you won't see much detail in it.



The image on the left is a good image of M27, but was done at a fairly short focal length that leaves the object of interest fairly small in the frame and doesn't show great detail. On the right, a longer focal length (2.2 times) was used, and shows much more detail in the object of interest without lots of dark, boring sky around it. Choose your targets based on your focal length and field of view for images that show more detail in the object you're imaging!

Raw Data

So, you've followed the steps outlined above. You have an object you want to image, you're in focus, your mount is tracking well ( or you at least know how long you can expose for before tracking errors show up), and you're ready to go. Let me start with a few suggestions for organizing your data during a session...
Once you've determined how long each individual image is going to be exposed for, you're more than likely going to do multiple exposures and make the final image by combining those exposures later. Make it easy on yourself and organize the data as you take the images, so you won't get confused later when trying to find all the pieces! If you're doing monochrome or one-shot color imaging, things are fairly simple: make a new directory on your computer (if your software supports this, and nearly all CCD camera software does) that gives the name of the object and the date you're imaging it. For example, make a new folder called "M42_Jan82003", and store all the images in that folder. Underneath that folder, I like to make additional subdirectories for each type of image that will be taken. If I'm doing dark frames or flat field frames (see chapter 2), I'll make directories called "Flats" and "Darks." If I'm using color filters to do RGB or LRGB imaging, I'll make directories for "LUM," "RED," "GREEN," "BLUE," etc. Keeping all of the seperate kinds of image files seperate makes processing them much easier later, especially if you're sleep deprived the morning after an all-night imaging session!
Also, if your software supports it, fill out the information fields that will be written to each FITS file as it is saved (observer name, telescope, focal length, etc.). If your software doesn't let you fill this out and have it saved to the FITS files automatically, then write a short text file that gives this information, along with anything else you consider useful (what guide scope you used, what the seeing was like, temperature, humidity, location, etc.) and save it in the object directory. The best way to learn from your experiences is to know just what was going on when you took a particular set of images. I consider keeping good notes essential to good imaging, and many times I've gone back to an older set of raw images, and found the notes I stashed away with them very useful. If your equipment acts up or gives you problems during the night, add this to your notes as well, as a reminder that you'll need to spend some time working on those problems on full-moon nights or when you get another chance!

A Very Important Note Regarding Histograms and Levels

As we progress throughout this tutorial, you're going to hear a lot about histograms. A histogram is just a graphical representation of the range of pixel values in an image. It shows you at a glance how the various pixel values (which indicate brightness values in a monochrome image) are distributed.

A histogram display in MaximDL/CCD software

The histogram shown above, from a finished image in MaximDL/CCD software, shows a "typical" distribution for a good CCD image. The graph is layed out with the horizontal axis representing pixel brightness values from 0 to 65,535 (for a 16-bit image), and the vertical height showing how many pixels in the image have that brightness value. Notice the tall hump in the white graph just to the right of the minimum (zero point) on the left -- the peak of this hump shows that the image has the highest count of pixels with a value fairly well above zero. The pixel count (and hence the top of the graph) trails off and down to the left from the peak, indicating a drop-off to zero or pure black, and slopes slowly down and to the right, towards brigher pixel values and ending at 65,535, the highest value that can be represented in a 16-bit image. A "good" histogram of a typical astronomical object always has a histogram with this basic shape -- with the peak of most of the background pixels having a value fairly well above zero, a slope down to the left towards zero, and a more gradual slope down to the right towards the maximum pixel value. Note the red and green "pointers" below the graph -- these pointers indicate the black point (red) and white point (green) that will be used for displaying the image data on the screen ONLY. In MaximDL/CCD, this is called Screen Stretch, and you can safely manipulate the red and green sliders to change how the image is displayed without affecting the actual data in the image. Only when you change the data using the Stretch menu item in MaximDL/CCD does the actual image data get changed. Some CCD software programs (most notably AstroArt) have an "autostretch" feature that WILL change the underlying image data automatically for you -- turn this off if you're using AstroArt, and only use their version of Screen Stretch.

A histogram that looks like the one above indicates several important things:
-- The full dynamic range that a 16-bit image can represent is being used
-- The "black point" is not set so that background pixels are clipped, avoiding a pitch-black sky and a severe loss of data
-- The count of pixels at the maximum (65,535) value is not too high, which would indicate a lot of saturated pixels


This image is displayed using the histogram settings above.
It shows a full dynamic range, no washed-out whites, and a
background that's dark gray instead of black. It's in good
shape for further processing.


Here's what manipulating the histogram does to your images:
First, I moved the "black point" slider to the right, well into the "hump" of background pixel values, so that the black point is set at just over 12000.

Histogram with black point at 12035

Here's what the image looks like with the black point set so much higher:

Look at the histogram again -- what moving the black point up does is set every pixel that is to the left of the red "black point" slider to a value of 0, instead of the range of values that they originally had. That means that all of the faint detail information that was in those pixels, ranges of varying shades above the sky background, is now gone. Forever lost. You'll never get it back again. You've just clipped off all that faint detail, thrown it away, and set the pixels to zero. This is a bad thing! You may very well want to have a contrasty background like this when the image is all done, but that's a decsion that should be made once all of your processing is complete, not when you're just getting started. In this case I only used MaximDL's screen stretch, so the sliders have only affected the way the image is DISPLAYED on screen and the data in the image itself hasn't changed yet -- but if I saved the image with these settings, I'd be saying goodbye to all that neat faint background data I worked so hard to acquire at the camera.

Here's another histogram with the same black point at just over 12000, but now I've also moved the white point down to the left:


Hisogram with black point at 12035 and white point at 33471
And here's what the image looks like with those settings:


Now we have an image with a jet black background, and whites that are way over-saturated and blown out. Lots of information at both ends of the histogram have been thrown away. Here's what you've really done to the image by using the settings above:


What the black and white settings really do

When you set the black and white points in a histogram control, effectively you're throwing away all of the data to the left of the black point setting, and all of the data to the right of the white point setting. The software you're using then takes the values only inside of the black/white sliders, and uses that as the data in the image. Anything to the left of the black point is set to 0, and anything to the right of the white point is set to 65,535. As you can see from this modified histogram image above, we're now only using about one third of the data that *was* in the image -- the rest has been thrown away. Once again, this is a bad thing! Until the very final processing steps, keep all of that data around to be manipulated and used in constructive ways, rather than throwing it all away at the beginning. Your images will show more detail, have a greater dynamic range, and will retain all of the data you captured when you shot the image with the camera.


A typical histogram from a raw, just-taken CCD image

The next histogram, just above, shows a typical pixel distribution from a raw CCD image, after calibration (if needed) but before any stretching, combining, adjustments, etc. You'll notice that it has the same basic shape as the first one above, but that the shape appears to be "squished" together. Unsquishing the histogram so that it covers the full 16-bit dynamic range is what is commonly called "stretching" the image. What you're really doing is stretching the histogram, or the actual pixel values, of the image. This "stretch" takes the existing values and spreads them out so they take full advantage of the available values.
Notice also that the high point of the second histogram -- the peak that shows were most of the background pixels are -- is way, way to the right of the zero point. This is an indication of sky background being recorded in the image. Even at a very dark site, the sky is not completely black! It's really a dark blue naturally, which records in monochrome CCD images as dark gray. Light pollution, moisture in the air reflecting light, dust particles, even naturally-occuring ionized radiation also bump the sky background level up away from black. When you see a histogram like this in a raw image, you may be tempted to "stretch" the image right away so that the black point is right up against the left edge of that big peak of data...
DON'T DO IT!
At a later -- MUCH later -- point in the image processing sequence, you're going to set the black point at an appropriate position. A position that will darken the background of the image, without turning it black. That point is NOT now! If you move the black point too far to the right, and do a stretch that affects the image data instead of just the screen display, you'll wind up with a completely black background, you'll lose the faint data that's just above the black point, and you'll have a very contrasty and unattractive image.

A CCD image whose black level has been set way too high. Faint image data is lost and can never be recovered, and the image is far too contrasty.


A CCD image with the black level appropriately set for more processing steps -- faint image data is preserved for later manipulation, and the black level can be moved to its final position after a lot more processing work is done on the image!

After calibration, and for most of the steps you'll take as you process your images, the background level should look as it does in the second image above -- a dark gray background, with the faint image data preserved for later teasing out with additional processing. If your image backgrounds at the beginning of processing are as black as the top image above, you will have lost data that can never be recovered, and the final image will suffer greatly for it.

The idea of leaving the background/black point set so the sky is gray instead of black is one of the hardest concepts to instill in your brain as you begin doing CCD imaging, since it just doesn't seem RIGHT, does it? It's also one of the most common mistakes made by beginning imagers (including myself when I was starting out), resulting in "clipped" images with jet-black backgrounds that are way too contrasty and have little faint object data to display. We'll cover setting the black and white points of your images in much more detail in a later chapter...for now, it's important to resist the temptation to set that background to black and save it for doing later on. Your images will thank you for doing so later!


A finished image, which had the black point of the original files set so the sky background was BLACK. Compare to below...


The same image, with the black point set as described above giving a gray sky until final processing was complete. See why you don't want black sky backgrounds?


Those are just the basics of acquiring good image data that will give you a solid base to work with. There's much more you'll need to learn if this is all new to you, but most of that will be learned simply through practice. I often tell people that astro-imaging is one of the hardest avocations to get GOOD at...with most new activities that people begin to learn, whether it's playing the guitar or working on cars, you get good at it by doing it, practicing as much as possible. That's also true for astro-imaging...the trouble is, we can only practice when the weather cooperates, our home/work schedules allow us to skip sleeping for a while, there isn't too much moon, etc. For most people who still work regular jobs and have families, those restrictions often translate into only a few nights each month to practice and learn imaging. It's hard to get good at something quickly when you can only do it a few times per month! Like anything else, however, the more you do it the better you'll get. Get out and image whenever you can -- the more you do, the quicker you'll see improvement in your techniques and the more you'll learn.

Tutorial Introduction
Chapter 1: Gathering and Preparing the Image Data
Chapter 2: Calibration -- Darks and Flats
Chapter 3: Aligning and Stacking Images
Chapter 4: Maximizing Your Data -- Histograms, Stretching, Contrast, Brightness, Gamma
Chapter 5: Dealing with Imperfections and Artifacts
Chapter 6: Basics of Color Images
Chapter 7: Advanced Color Image Processing
Chapter 8: Advanced Techniques -- Masking and other tricks
Chapter 9: Summary and Final Thoughts











All text and images Copyright (c) 2003, Paul LeFevre
Mail me with comments & criticisms!