CCD Image Processing

John A. Blackwell
johnb@regulusastro.com

Introduction

Welcome to the first in a series of papers discussing the processing of astronomical CCD images. This is an exciting and rapidly developing field for both amateurs and professionals alike, and it has never been easier for amateurs to produce professional results with basic CCD equipment and small telescopes. These papers will walk the amateur through the most fundemental aspects of image processing and end with advanced topics like Maximum Entropy Deconvolution and LRGB color imaging. I hope you find this information useful.

If, while you read this, you find that there are terms you do not understand, please check the CCD FAQ I have posted at: CCD Frequently Asked Questions. It is by no means complete, but it is a good start.

Why Process?

There are many reasons to process images after they have been taken:

Signal Signal Signal

The most important thing to remember about CCD imaging, aside from all the other "most important things!", is to get a sufficient signal. This maximizes the signal to noise ratio and insures that you have enough information to process smoothly. Raw images should have histograms that spread across from minimum (black) to at least 75% pure white for the object of interest. You might overexpose some stars. This might cause blooming. The solution to this is to take many integrations of the object and add the exposures together. Some people have been known to add 60 to 100+ images together to make a final image.

Setup your workstation:

An important step to take when processing your images is to set the brightness and contrast of your workstation's monitor. Below is a greyscale step pattern that you can use to do just this. This scale ranges from solid black to solid white. Be sure that you can see the difference between each step in the scale.

Steps

The Order of Operations:

The order in which you process an image is sometimes important. Dark frames should always be subtracted from an image first, then deal with flat fields and bias frames if required or desired. After that preliminary processing, you can then move on to the more artistic side by doing stretches, filters, etc.

Dark Frames

Use dark frames! Subtract them from your image. This is probably the single most effective way to clean up your images. Be sure to take dark frames in absolute darkness, at the same temperature as the image you are editing, and for the same exposure time. If you take a 5 minute shot of M-42 in Orion at -20 degrees C, then take a corresponding 5 minute dark frame at -20 degrees C as well. Some software will allow you to use dark frames of different length and temperature using an advanced auto scaling process behind the scenes. The results will never be as rewarding as using the proper scales. Remember that dark frames can be saved for use later! Do not delete them. A library of these files in a separate directory is very useful later on. Name them something helpful like: DRK_5min_n20C.FIT This way you can tell them apart. For even better results, many dark frames can be averaged together to form a "master" dark for a given temperature and integration time. Below is a comparison of the same image of NGC 7332 without a dark frame subtracted, and with one subtracted. The image was a 5 minute integration through a C8 at f/6.3 with a non-ABG, non-E ST-7 cooled to -20 degrees C.

Before dark frame:After dark frame:
beforeafter

If you take many images to add together, then you must subtract dark frames from each and every one of those images prior to adding them together. It is not possible to add the images first, then remove dark frame information afterwards.

What do dark frames do? They remove, by subtraction, noise formed primarily from heat and readout errors from the CCD chip itself.

Flat Fields:

Flat fields are definitely overrated for the most part. They have their place in certain situations. They reduce unwanted signal effects caused by varying sensitivities across the CCD chip's surface, optical path vignetting, dust on the lens, etc. They must be used if you are planning to make photometric measurements of variable stars or asteroids. The problem is that taking flat frames is not an easy task. In fact, it is the difficulty in obtaining a good flat field that prevents most amateurs from using them. There are two main methods to get the flat field image: nature's way and the artificial way. Nature's way is to image the dusk sky through the scope. This allows you about 30 minutes worth of time before stars come out. The artificial way is to image, through the scope, a light box or projection screen that has been evenly illuminated. This latter method gives you greater flexibility as far as timing and control. When taking flats, remember these points:

Bias Frames:

A bias frame is an image, taken again with the lens cap on, for a 0 second duration and at the same temperature as the light frame. This is a "map" or record of the bias signal and can be removed by subtracting it from the final light frame image and its dark frame during processing. This is a very subtle image maipulation and really only becomes necessary when doing high precision photometry.

Some software like MaxImDL/CCD allows the automatic use of flats, darks and bias frames. You just have to point the software to your processing directories, and it will do the rest. This is pretty handy.

Stretching:

Stretching is a term used when spreading the histogram of an image out such that the dark end is a true black and the high end is closer to a true white. Below is an example of a linear stretch done on an image of NGC 7479. The signal was just strong enough to see the galaxy before a stretch was performed. After the stretch, the galaxy was made much more visible, and a satellite track was also discovered!

Before linear stretch:After linear stretch:
beforeafter
before
after

Below each of the above images is its corresponding histogram. A histogram is a graph of the number of pixels of each brightness level. The horizontal axis is the brighness level (black on the left, white on the right). The verticle axis is the number of pixels. You know you have a dim image when all the pixels are on the left side of the histogram. Correspondingly, you know that you have maxed out the image when you have pixels at the extreme right of the graph.

Using Multiple Images

John A. Blackwell
johnb@regulusastro.com

For those of you who missed the first part of this series, please see the Papers section of Regulus! for the past issues.

Introduction

This month the image processing discussion will cover stacking and averaging of multiple images. This is important for anyone looking to obtain the finest in CCD images. It can also be time consuming, which is why even astronomers appreciate rainy nights!

Why Multiple Images?

There are plenty of reasons. Let me list the major ones here:

  1. Use of a non-antiblooming CCD chip: only short integrations can be made of bright objects with faint details.
  2. To beat atmospheric seeing.
  3. To increase the signal to noise ratio.
  4. To do RGB or LRGB (CMY, etc) color imaging.
  5. To improve upon tracking errors in a mount.

Short CCD integrations are notorious for having a grainy appearance. This is due to the low signal-to-noise ratio of short images. The noise shows up much more prominently. A good way to avoid this is to just take longer integrations. There are things that will prevent this though. Let us take a typical subject that most amateurs will recognize: M-42, the Orion Nebula. This is a bright object. It is a good starting place for film users, but for CCD imagers, it presents a challenge. The edges are faint, and the core is bright. The same is true for the Andromeda Galaxy M-31. If one images these with one long integration, the core areas will "burn out" and show up as an overexposed spot on the CCD image. To avoid this, take many much shorter images and add them together. Various masking techniques also help, but that will be discussed later.

Also, if the CCD system does not have antiblooming, one is likely to get bright star blooms with long integrations. My ST-7 non-E non-ABG will bloom in under a minute with an f/6.3 8" scope on an 8th magnitude star. This creates quite the challenge. The solution is to add many short integrations together.

Take Care!

Brightness levels in CCD images are what are being added together when stacking multiple images. Most imaging software will allow one to view the minimum, maximum and average pixel brightness values. MaxIm DL has this under the "View Information" menu item. Note that all CCD imagers have a limit as to the maximum value for any given pixel brightness level. The ST-7 has a maximum value of 65536. Any values above this are quite confusing to software working in traditional FITS format. Some software will lop off the high value and leave it at 65536 for complete white. Other software will get confused and even crash. Some software will bring the values into a negative range, and some software will allow it, but requires one to save the image in a 32-bit format. To still utilize the information one might have in extra images, one can average the images together.

Averaging Images

Some times the image has the correct density of brightness, but the signal to noise ratio is still too low to get rid of image graininess. To fix this, one can average a bunch of images together instead of adding them. The software you use will take the sum of the pixel brightness for each pixel then divide that value by the number of images being averaged. The result is a cleaner looking image.

How is all this Done?

Well, it all depends upon the software you are using! Most CCD imaging software will have some method to add/sum and average multiple images together. Some do not have provision to align the images, a vital part to getting a fine image. Alignment should be done on a dubpixel level. In other words, the images to be added should be aligned using the calculated centers (or centroids) of stars across the field. Once aligned, the images are summed together.

Not to be an advertisement for software, but here is an example using MaxIm DL software from Cyanogen:

First, the multiple files are selected and opened into memory using the Files Combine command:
Combine Dialog

The Combine Files alignment dialog then automatically opens to allow the user to select between a series of options. One can Sum or Average the files. One can use automatic star matching alingment, or do the star selections manually. The user can even nudge images relative to each other to make very fine adjustments to their alignment. This is handy when processing planetary images which have no stars in them.
Alignment Dialog

An Example

60 sec integration This first image is a single 60 second integration of the Bubble Nebula (NGC 7635). Note that there is a star on the right of the image that is begining to bloom. The nebula has yet to really become visible in this shot. This is a perfect opportunity to sum together a whole bunch of images.
10 summed 60 sec integrations

This image is an addition of ten 60 second integrations. Note that the nebula is now more visible and the star is not blooming any more than it already has. One could even add together twenty 30 second integrations for a similar image density, and that star would not bloom at all. For more signal, one could image this nebula many more times over many nights and add it all up later.
DDP

This last image is the same as the one above, but the Digital Development Process (DDP) has been applied to bring out the faint nebulosity. Also note a satellite track that crossed the chip during one of the exposures. DDP also caused that odd looking halo around the blooming star. This is a side effect of that processing technique.

CCD Image Processing Part III: Filters

Introduction

This month the image processing discussion will present information about the various processing filters that many popular softwares allow the astronomer to use. These filters can do all sorts of wonderful and terrible things to an astro-image. The temptation for the novice will be to over-process an image to a point where the subtle aesthetics of the image are lost. One must try to be as objective as possible while using filters. They have different uses and different results.

What are Filters?

Filters are mathematical methods of manipulating an image. They are used to bring out hidden details in an image, blur noise, emphasize certain details, hide flaws in the imaging equipment, etc. There are many different types of filters, and many you can create yourself. This ability can give an amateur hours of fun during rainy nights when observing is impossible. The examples within have been created using Cyanogen's MaxIm_DL/CCD software. Its features are similar to several other software packages. In fact, many of the more common filters are available in the software that comes with a CCD camera.

Low-Pass Filtering

Low pass filtering is good at getting rid of noise and graininess. Unfortunately, it is also good at getting rid of image detail. There is a fine balance between noise reduction and image sharpness. A typical low pass filter will average the pixel in question with the one above, below, to the left, and to the right of it. The filter will have a matrix thus:

0+10
+1+1+1
0+10
An example is the following image pair of M-27 in Vulpecula. The Image on the left is the original, unfiltered LRGB image. The one on the right has had a low pass filter applied to it. Note that the stars are less pinpoint, the nebula is more diffuse, and some faint stars are no longer even visible.

original low-pass

Median Filters

Median filters are stronger than the low pass filter discussed above. These filters average the pixel in question with all of its eight surrounding pixels like this:

+1+1+1
+1+1+1
+1+1+1
Use a true median filter like this when your star images are greater than four pixels across. At that resolution, the median filter will work well to remove noise and will not harm the detail of the image too greatly. Below is an example of the median filter used on the same M-27 image used before. On the left is the unfiltered image. On the right is the median filtered image:

original median

High Pass Filters

High pass filters are often called sharpening filters, because they have the effect of making images sharper. Unfortunately, they also increase the effects of noise, making it sharper too. The solution is to start out with a low noise, high signal image in the first place. A somewhat powerful sharpen filter is defined by the following convolution matrix.

-1-1-1
-1+9-1
-1-1-1

What happens here is that for any given pixel, its value is multiplied by 9, while its surrounding 8 pixels' values are mutiplied by -1. An example follows in the images below. On the left is the familiar unfiltered M-27, while on the right is the same image as passed through a sharpening filter. Note that stars appear brighter and more defined. Details in the nebula are more defined as well. Looking carefully, one will also note that the graininess of the image has also increased a bit. This is the "magnification" of noise in the image.

original sharpen

Unsharp Masks

One of my favorite filters to apply to planetary images, and when I just want to get a little bit sharper detail, is the unsharp mask. This filter has come to us through photographic darkroom technique and has since been digitized. Now, with a simple click of a button on a PC, one can do all of the following steps at once: Take the original image, blur all the smaller details (say within 10-15 pixel square areas) to create a "mask", sum three times the original image with negative two times the mask. The result is an image with improvements in smaller details that are often blurred. Below is an example of unsharp masking taken a bit to the extreme to give an idea as to what it can do. It is easy and tempting to go overboard with unsharp masks. Note in the below image that stars look brighter. This is because the mask has made most stars the same size and pixel brightness. The overall brightness changes between stars will be reduced. Also note that any blooming spikes will also be enhanced. Note one such spike on a star on the center right of the image. Nebulosity detail will be enhanced too, but note that the edges of the stars within the nebulosity obtain a dark area around them. This is a classic outcome of a heavy unsharp mask.

Fast Fourier Transforms

This is one of the first useful advanced filter one might use to enhance images. First, a word of explanation. A Fast Fourier Transform (FFT) is not what most people wish to do to an image. Just doing a straight FFT to an image will result in a frame full of garbled mush! What most software does to an image when it does their version of an "FFT" is: perform an FFT on the image, pass the result through other filtering processes, then reverse the FFT. The result can be quite remarkable. FFT's done by themselves will do the following. Edges in an image where brightness changes are slow (i.e. nebulae) will produce an image that is brighter on the corners and edges. If the brightness changes are fast and dramatic (stars on a black background), the FFT will produce an image that has bright centers with dark edges. This is not really what one wants! Below are two examples of what can be done with FFT's interlaced with a couple of kernal filters. In this case, the first is an FFT followed by a high pass sharpening filter followed by the FFT reversal. All this is done in one step in the software. The second is like the first, but a low pass filter has been used. Usually, after these filters are applied, a normalizing stretch would be done to rescale any odd brightness changes that have resulted.

FFT: High Pass

FFT: Low Pass:

Deconvolution

One hears a lot about deconvolution these days. It is a filter operation of choice it seems, often with "mystical" abilities to sharpen images that were poorly tracked or focused to begin with. Well, it has some neat abilities, but do not use deconvolution as an excuse to not guide or focus to the best of your abilities. Remember the old "garbage in garbage out" (GIGO) rule. First deconvolution is done on monochrome images. Second, it will sharpen and bring out hidden details. Third, it requires a lot of playing to get it right. This is how it works: First, the raw monochrome image has to be calibrated. Subtract dark frames, and process with flat fields first. Add any images together for noise reduction. Do not stretch the image. Do not apply any other processing steps or filters to the image before deconvolution or maximum entropy deconvolution is performed. Deconvolution is the reverse of convolution. Convolution is when an image is disturbed by "noise", focus, tracking, atmospheric seeing, etc. This convolution can be approximated by a point spread function (PSF) (i.e. a fuction that spreads out the light from a theoretical point of starlight in a disturbing way) and an FFT. The theory is that if this process is reversed (i.e. take a FFT of an image, divide the point spread function into it, then reverse the FFT), the image will revert to what it should have been before being convolved by the disturbing forces. Good theory. Now, it often creates mush. When one selects the right point spread function (to tell the software how a star has been blurred away from a perfect point), and one does the right amount of iterations, the result can be spectacular. Below is an attempt that almost works well. The stars have been made smaller and sharper. Nebulous detail is more pronounced and sharper. Bright stars in the nebula have small circles of darkness around them: a well known problem with deconvolution. Maybe fewer iterations or a better PSF would have helped here. I rarely use deconvolution. Instead I like to work on nights of better seeing and spend more time focusing. This isn't the sure cure to a perfect image, but it makes reliance on filters less necessary. Some nights when it's raining, it can be fun to see if deconvolution works well on any given image or not. If it does, then good!

Digital Development Processing

This is the new-comer to the world of image processing. Used to bring out faint details without burning in the already bright areas, Digital Development (DDP) can be quite helpful. Like any other processing technique, using too much DDP will result in a grainy image. Typically, one selects the area of the image that should be considered background or darkness. Then an area of midtone brightness should be selected. The software then reconstructs the spread of brightnesses across the histogram such that dimmer areas are made brighter, but bright areas are left relatively unenhanced. The result is that faint areas of nebulosity and faint galactic arms are made more visible, but the bright areas have not lost their definition by being made too bright. The process was created by Dr. Kunihiko Okano and combines both unsharp masking and gamma stretching in one fast algorithm. Many user-tweakable settings are possible. The unsharp mask requires either an FFT or kernal filter for blurring the mask. Various levels of blurring are possible. I suggest playing around and taking many notes. Soon you will discover what many of the various possibilities are.

Make Your Own! Have fun and experiment.

Many software applications allow the user to create their own masks and filters. Kernal filters are a great place to start. Try various combinations to create special effects. Try, for example, the following kernal:

-1-1-1
-1+1+1
+1+1+1

As you see, the possibilities are endless and fun. Do take notes. It will help later on when you try to remember just what you did to that lovely galaxy image months ago.


Contents What's Up Feature Papers Photos
Links Observations Spectra Sketches

Last Modified: 3/19/03 8:55p
This page:© Copyright 2005 by John A. Blackwell