Russell Croman Astrophotography  





This plug-in for MaxImDL 3.07 or later provides a different method for combining multiple images.

Often, long-exposure CCD images contain spurious dots or streaks caused by cosmic rays striking the detector during the exposure. If it weren't for these, the best way to combine multiple images would be to average their pixel values. This yields the best signal-to-noise ratio gain of any combination method. However, the spurious pixel values resulting from cosmic ray hits can be bright enough to be visible in the averaged image, especially when the contrast of the image is increased in post-processing.

To eliminate the cosmic ray hits, the median combination method is often used. This is very effective at eliminating spurious pixel values, but comes at the cost of an increase in noise relative to averaging. In fact, empirical tests show that the median combination method almost always results in a loss of about 1.7dB in signal-to-noise ratio relative to the averaging method. This is a high price to pay for eliminating cosmic ray hits -- it corresponds to effectively throwing away about one third of your exposures!

The "sigma-reject" algorithm provides a good compromise between these two methods. Given enough individual exposures to work with, it can effectively eliminate cosmic ray hits at a minimal loss of precious signal-to-noise ratio. Five images is about the minimum number to see much rejection without a significant decrease in SNR. The plug-in will combine as few as three images, but this really isn't enough information for any algorithm to work with.

Features of this plug-in

  • Works directly on images in MaxImDL... no back-and-forth between multiple programs.
  • Rejection threshold automatically defaults to an appropriate value based on the number
    of images being combined (less than 0.1dB loss in SNR).
  • Option to create a "difference" image showing the rejected pixels (cool!).
  • Written in C++... it's fast!
  • Key FITS header information is carried over to the combined image.

Download/Installation Instructions

  1. Click here to download the SigmaReject plug-in.
  2. Save the file (SigmaReject.dll) in the MaxImDL folder, which is probably:
    C:\Program Files\Diffraction Limited\MaxIm DL 3
  3. Start MaxImDL.
  4. From the "Plug-in" menu, select "Add/Remove Plug-in...."
  5. In the "Manually Add Plug-In" section, click "Browse...."
  6. Navigate to the MaxImDL folder and select the SigmaReject.dll file.
  7. Click "Open" in the browser window.
  8. Click "Close" in the Add/Remove Plug-In window.
  9. The plug-in is now installed!

Operating Instructions

  1. In MaxImDL, open the images you want to combine. Only the images you want to combine should be open (the plug-in combines all open images).
  2. If these are dark or bias images, skip to step 4.
  3. If these are object images, perform any calibration, deblooming, and alignment steps needed.
  4. In the "Plug-in" menu, select "SigmaReject Combine."
  5. You should see a dialog box appear if there were no errors (e.g., images of differing size, etc.).
  6. Enter the desired rejection threshold, if different from the default. The default value should yield less than 0.1dB signal-to-noise ratio loss. Lower values reject spurious values better, but rapidly increase the noise.
  7. Choose whether you want to enable image normalization. This should be selected for light images, deselected for dark or bias frames. The plug-in tries to set this appropriately by default.
  8. Check the box to create a secondary rejected-pixels image if desired.
  9. If you are combining flat-field images and you have enabled normalization (recommended), make sure the "These are Flat-Field Images" check box is checked. Otherwise normalization may fail, giving weird results.
  10. Click OK.
  11. A progress bar will appear and you will see some activity in the MaxIm window. Wait for the operation to complete.
  12. If you chose to have a rejected-pixels image created, this will be on top. Inspect it as desired.
  13. The combined image will be named "SigmaReject." Save it to an appropriate file name.
  14. If normalization was selected, the source images in memory will have been modified. You can save or delete them at your discretion.
  15. You may need to try different settings for the rejection threshold to get better cosmic ray hit rejection, especially with fewer images. The default rejection threshold is set slightly conservatively (i.e., biased slightly to keep rather than reject pixels.)


Please send any bug reports to me by email.

Version History

0.2 -- 15 Dec 2002
  1. Modified sigma-reject algorithm to iterate twice (better SNR).
  2. Added copying of DATE-OBS, FILTER and IMAGETYP keys.
  3. Fixed a bug that caused a crash if a FITS key didn't exist.
  4. Added a checkbox to help with normalization of flat-field images.
0.1 -- 8 Dec 2002
  1. Initial Release

Case Study

I needed a good case study to test the performance of the SigmaReject plug-in. I chose a long-integration H-alpha data set of M42, the Orion Nebula. This nebula has some quite dim extents that receive a lot of contrast enhancement in post processing, so good signal-to-noise ratio in these areas is critical. Also, the fairly long integration time (87 minutes total) gave plenty of cosmic ray hits on the both the dark and light images.

The data set consisted of the following raw images:

  1. 29 H-alpha exposures, 3 minutes each.
  2. 19 dark frames, 3 minutes each.
  3. 10 flat images
  4. 10 darks for the flats

Three processing runs were done to do a fair comparison of the performance of the plug-in versus "standard" processing methods. The first run was a baseline, using median combination for darks and averaging for lights:

  1. Combine the darks for flats: median, no normalization.
  2. Calibrate the flats using this result.
  3. Combine the flats: averaging.
  4. Combine the darks: median, no normalization.
  5. Calibrate the light images using the above dark and flat.
  6. Align the light images using MaxIm's auto star matching algorithm.
  7. Combine the calibrated and aligned images: averaging.

The second run simply replaced step 7 above with normalized median combination, which is what would normally be used in a case like this to eliminate cosmic ray hits.

The third run used the SigmaReject plug-in for all combination operations:

  1. Combine the darks for flats: sigma-reject, no normalization, default threshold.
  2. Calibrate the flats using this result.
  3. Combine the flats: sigma-reject, with normalization, default threshold.
  4. Combine the darks: sigma-reject, no normalization, default threshold.
  5. Calibrate the light images using the above dark and flat masters.
  6. Align the light images using MaxIm's auto star matching algorithm.
  7. Combine the calibrated and aligned images: sigma-reject, with normalization, default threshold.

A small area of dim extent near the background level was cropped out of each image. Screen stretching was applied using the same limits for each image. Here is a screen snapshot of the results:

In the averaged image, the signal-to-noise ratio is good, but there are many speckles due to cosmic ray hits. This can be seen by comparing with the median-combined image next to it. The median image gets rid of the cosmic ray hits, but there is a very evident increase in noise relative to the averaged image. This is apparently the ~1.7dB loss mentioned above.

The result from the plug-in is shown below the other two. Close inspection confirms that the signal-to-noise ratio of the averaged image is retained, and the cosmic ray hits are eliminated.

The performance increase over median combination is also very evident in the dark frames:

The median-combined image can be seen to be noisier than the image produced by the SigmaReject plug-in. This is even more evident when comparing the difference between the median and sigma-reject images and the averaged image. Again, the exact same screen stretch settings were applied to both images:


The Sigma-Reject Algorithm

Here is what the sigma-reject algorithm does:

  1. From the set of corresponding pixel values from each source image, compute the mean (average) and standard deviation of these values.
  2. Compute a new mean, omitting pixels from the above set that fall further away than threshold standard deviations from the mean. Use this new mean as the output value for this pixel location.
  3. Repeat steps 1-2 for every pixel in the final image.

The Doubly-Iterated Sigma-Reject Algorithm

This is an extension of the standard sigma-reject algorithm, and is what is implemented in SigmaReject. It produces both better rejection of artifacts, and better signal-to-noise ratio. Rejection properties are especially improved for relatively faint artifacts, such as satellite trails.

  1. Compute the mean and standard deviation as above.
  2. Reject spurious values and compute a new mean value as above.
  3. Compute a new standard deviation based on this new mean, and using only the accepted pixel values from step 2.
  4. Using this new, better estimate of the standard deviation, repeat the pixel rejection process, and generate a new mean value from the accepted pixels.
  5. Repeat for every pixel in the final image.

The idea behind iterating twice is that the original standard deviation computation is wrong in the presence of an artifact; it is too large. Re-computing the standard deviation after rejecting spurious pixel values results in a better estimate of the "true" standard deviation, which can then be applied to the second rejection process.