Cleaning Cosmic Rays from Image Sets

Published July 2013

This note describes the Clean Image Set command as taken from the Mira User's Guide. This tool is provided in Mira Pro x64. This is exceptionally effective for removing transient artifacts such as cosmic rays and other radiation events as well as sporadic hot pixels. The Clean Image Set command compares the members of an image set to determine statistically what pixels are transient and should be corrected. The results can be superior to that obtaining using other methods because this method does not detect sharp image features as transients and remove them, this smoothing the image and degrading its analytic value. Several detection and correction options are available to meet specific image needs.

This command identifies and, optionally, repairs artifacts which are caused by a variety of sources, including cosmic rays and ionizing radiation events, as well as hot pixels. In this document, the term "event" refers to any pixel value in one image that is not persistent, within the noise, throughout the image set. This technique therefore detects and corrects events that occur at identical coordinates in only 1, 2, or a few of the images in the image set. Hot pixel "events" are removed when they do not align at the same pixel coordinates in different members of the image set, for example, after the images have been registered. You also can use this command to clean cosmic rays from long exposure, weakly illuminated flat field calibration frames that are not aligned, since the persistent flat field structure is automatically aligned. When an image set is registered before cleaning, poorly corrected hot or cold pixels shift around and appear as events, and the method detects them the same as true radiation events. For a demonstration, see the Example, below.


This method detects outlier pixels by comparing the values at the same pixel location in a series of images. In comparison, most cosmic ray detection algorithms use information from neighboring pixels within the same image. Using neighboring pixels within the same image makes it difficult to separate outliers from sharp features, such as the peaks of stars. The current method is not sensitive to pixel values in the neighborhood of the target pixel because the sample of pixel values used for rejection is tracked through the image set. However, this makes the requirement that the images must be registered in software, using the Register Images tool, the Align by WCS command or the images must have been aligned when acquired.

This method differs from contrast-based methods that are used for single images, such as the Apply Cosmic Ray Filter image calibration method and the "Cosmic Ray Filter" option in the Spatial Filters command. The term "contrast" refers to the value of a pixel relative to its neighbors. The present method detects events using information from variations in the same pixel throughout the image set, whereas a contrast-based method detects events as outliers relative to pixels in the surrounding neighborhood. A contrast method has difficulty separating outlying pixel values from rapid changes in the brightness of persistent features such as stars.


This method will detect a varying or moving object as an "event" and reject it from the images. Do not use this method if the image set contains a target object or feature that is varying in intensity or position between the members of the image set.

Cleaning also can be done when images are combined using Sigma Clipping, Alpha Clipping, the Median, or some other image combining methods. The present command does not combine the images but instead it identifies and, optionally, repairs the events occurring in the separate images. If you want to combine the cleaned images, use the Combine Images command. In the present command, most Repair Method options fix the event pixels but the "Set Pixel to Zero" option prepares the images for combining by the Masked Mean Value method (the "Mean - Masked by 0" option in the Combine Images command).

This method will identify outlying pixel values regardless of what causes them. Therefore, you can use it to clean cosmic rays and other radiation events as well as dead pixels and under corrected hot pixels. For many applications, you do not want to repair too many pixels. The Verbose Summary option lists not only the number of events detected but also the number of events as a percentage of the total pixel count. In the example below, cleaning was done using settings shown above, which resulted in a percentage of 0.2 to almost 1%. These values would be quite high for 2 minute exposures if all the events were caused by ionizing radiation of some type. In these images, the algorithm is also detecting a number of pixels having poorly corrected dark current.



Below is a comparison showing the defects in all images (top), image 1 before cleaning (middle) and after cleaning (bottom). All images are zoomed 2x so that every pixel easily can be seen.

The topmost image is boosted to show faint details. Notice the streak which was created by the minor planet which moved during the time the image set was acquired. Also seen are many point defects spread among the 9 images. In particular, notice the numerous clusters of 9 points which show a single hot pixel that was moved around by the image registration process.

The middle and bottom images show only image 1, not a combination, or "stack", of the cleaned images. In the bottom image, you can see that all the point defects have been corrected.

In the middle image, notice the radiation event about 1/4 the image width and height inward from the lower left corner. This point falls on the bottom middle edge of a faint star. In the lower image, notice how it was effectively repaired while preserving the star.

Overlapped view of 9 images before cleaning (shows defects in all images):


Image 1 before cleaning:


Image 1 after cleaning:

Notice that only image 1 is shown before and after cleaning. Using the Clean Image Set command, every image is individually cleaned, and that sets this method apart from cleaning based on ranking or clipping during image combining or "stacking". After processing, the clean images are still separate  and may be either combined or used individually. The advantage of combining a cleaned image set is that it allows you the freedom to choose combining methods that do not involve bad data rejection.

Which Pixels were Rejected?

Mira offers the option to view a map of the locations of all rejected pixels. Below is the pixel rejection map that is produced when Display Rejection Map Image is checked. The Map is an image that contains the index of the image in which the event was detected. Using the mouse pointer or a plot, you can determine which pixel was rejected from which image. For example, a value of 1 indicates a pixel rejected in image 1 of the image set. Near the upper right of the image, notice the moving blob which corresponds to the minor plant Xanthippe that was moving during the acquisition of the image set. The trail has values ranging from 1, at the lower right, to 9 at the upper left, which corresponds to images 1 through 9 of the image set. This illustrates the limitation of the method: it will detect the pixels of a "significantly" variable object or transient object as an "event" and reject it. How significant is "too significant" depends upon the image properties and your particular application.

Rejection Map Image


Learn More

Name  *

E-mail  *

Item of Interest





Verification *