Astronomical Image Processing Software
StarStack is a software package for processing and enhancing astronomical photos. This software is work-in-progress, so more features may become available in the future. The features in the current version include:
- Applying dark, bias and flat corrections to an image.
- Alignment of multiple images prior to stacking.
- Stacking multiple images for S/N enhancement.
- Stacking multiple sequential short exposure images to obtain an equivalent long exposure star-trail image.
StarStack is a 64 bit application, and is available for download from the Microsoft Store for Windows-10 at
Images are loaded under the File menu. The images are not loaded into the computer memory at this this stage, but only the file information and file location are read and stored. If the file on disk is subsequently deleted after it's information has being loaded, then it will not be found during the later processing steps.
The dark, bias and flat images should be loaded under the appropriate menu load item. Three file formats are supported and are JPG, PNG and TIFF formats. The image file information is stored under 7 categories, depending on how it was loaded or the processing step. These are shown by the 7 tabs on the left side of the main application body. These are:
- Image data. Data that has been loaded using "Load Image Files", which will be just a regular photo.
- Processed. Data that has come out from the "Processing" step. Manually aligned data is also within this group.
- Auto-Aligned. Data that has come out from the "Auto-Align" step
- Stacked. Data that has come out from the "Stacking" step.
- Dark. Data that has been loaded as a Dark Image, or from Dark Stack pre-processing
- Bias. Data that has been loaded as a Bias Image, or from Bias Stack pre-processing.
- Flat. Data that has been loaded as a Flat Image, from Flat Stack pre-processing, or a Modeled Flat image from the Pre-processing.
The workflow is divided in to 6 main steps. These are:
- Load the data, and select the required images.
- To determine optional processing parameters and stacking the dark, bias or flat images.
- Applying the selected processing options to an image. The processing steps are applied sequentially in the order of the steps as listed.
- Automatic Alignment <optional>.
- Manual alignment is a separate process that is done in the main processing section, and can additionally be done preceding automatic alignment.
- Image Stacking
- Enhancement <nothing here yet>.
- For future versions.
Data Loading and Saving
The image data files are not actually loaded into memory when a File->Load task is performed. Only the file header and EXIF data (if applicable) is read and the file information is stored in memory and displayed in the file list on the left side. When a later pre-processing or processing step is done, the image file is read from disk into memory, the processing performed, then the results is written back to disk. The information for the new file(s) created are updated to the list.
As an example such as Dark Stacking, only one file at a time is read from the disk and added to the stack, then discarded, before reading the next file and adding to the stack. There will be some tasks such as median stacking which require all files to be in memory before processing can start, but where applicable, files are only resident in memory when needed. The reasoning behind this, is that the software is less likely to have memory overload problems if a very large number of files were being simultaneously processed.
The saved file output format can be selected under Edit->Parameters menu. Currently, PNG format is shown as the default Save format, which maybe not what you want.
- Saving as TIF files are supported, but it is uncertain if OpenCV is using full 16 bit option for TIF files.
- For JPG format, 100 is optimal quality and maximum file size. It will still be slightly lossy, but will be as good as can get with JPG.
- PNG format is reported to be lossless and the parameter is the amount of computation effort that is applied to compress the file. 9 is maximum effort for a smaller file size. 3 is apparent a good compromise. 0 is no compression and quickest.
If you use PNG with quality = 9, the file save process may be quite long at the completion of each processing step. The quality of the image wont be any different from other quality options, but it will have a smaller file size. A value of 3 seems a good compromise.
Individual files can be selected (or "checked") by clicking on the file names. In the processing menus that follow, only the "checked" images are processed.
Right clicking on a file name brings up the Image Viewer.
For more file operations (see below), first click on the file-type to highlight it, then next right-click on the same, which will bring up a menu that lists some options that can be applied to the files under that file-type. In the example below, all the images are initially unchecked, and are all converted to checked. Note that the "Remove Unchecked Images", only removes them from the software data base, and they will still exist in the Windows File Manager.
Some workflow scenarios are shown below. These are grouped into workflows that don't have any dark, bias or flat images, and those that do. The simpler workflows don’t use dark, bias or flat images are shown in the first diagram below. Of these, the simplest option is to simply load a number of images and stack them all together. The more complex workflows include alignment and image processing.
Within the main processing workflow, any of the options shown can be selected. The minimum number of processes expected is one process and the maximum is all available options for processing. The options are not dependent on each other, but they will be performed in the order from top to bottom as shown on the Processing page. All of the selected processing options are done with-in one read/save cycle, to avoid image degradation that may occur if using multiple saving operations and a lossy image (JPEG) saving method is selected.
There are two main ways to view an image.
- The first way is to single-click on a file name when the “Preview and Exif” tab is at the front
- The second way is to right-click on a file-name and a separate ImageViewer will pop up.
There is a third type of image window that may automatically come up at times for some processing options, and this is from OpenCV. This window is controlled by the processing.
Pre-processing steps are steps that dont have any immediate effect on any images. The pre-processing steps either assist in determining processing parameters, or compute auxillary files such as dark, bias and flats for later application to the image files.
- Dark/Bias/Flat stacks. Computes a mean stack of the checked files that are loaded as either dark, flat or bias
- Flat modelling. Simulates a flat file based on a single parameter called “flat coefficient”. A larger value has a greater falloff towards the edge of the image. An image is required to be present in the image list before this option can be run, since information on the image size is needed and is got from any file in the flat list.
- ADR. This is an attempt to reduce the severity of atmospheric dispersion that occurs on images shot at lower altitude angles close to the horizon. It simply shifts the red pixels down by a certain pixel count, and shifts the blue pixels up. The photo angle relative to the horizon is required, and is the parameter called camera angle. Note that if doing eye-piece projection photography, an additional 180 degrees needs to be added (or subtracted).
- Manual Alignment shifts. Allow to identify a single, or a pair of points on each image for later alignment.
- Single point alignment means that the images will be aligned at the selected point by X and Y translations.
- Two point alignment means that the images will be first aligned mid-way between the 2 selected points by X and Y translation, and then a “best fit” rotation is applied so the two selected points will overlay. If the points were not accurately picked, or the images suffer from lens distortions, then the final overlay may not be exact.
Six processing option are available. The processing is applied in order from top to bottom. Only the processing options that are checked are applied.
- Dark Subtract. A dark image is selected from the dark list, and the correction applied.
- Bias Subtract. A bias image is selected from the dark list, and the correction applied.
- Flat Subtract. A flat image is selected from the dark list, and the correction applied.
- Flat Model Subtract.
- AD Reduction. ADR is applied using the parameters determined during pre-processing.
- Manual Alignment. Manual alignment is applied, using the parameters determined during pre-processing.
- Negative Image. A negative image is computed.
Manual Image Alignment
Manual image alignment is a two step process, and is done in the Pre-processing and Processing sections.
First the user picks alignment points in all the images, and this is done under the Pre-Processing tab. There are options to pick either a single alignment point or two alignment points.
The second step after picking the alignment points, is to align the images and this is done under the Processing tab. Manual Alignment is one of the check-able processing options. If only alignment is required, then only Manual Alignment checkbox should be checked. After alignment, the next step would be to stack all the aligned images, and this step proceeds automatically if the checkbox for stacking is checked (it is checked by default).
Alignment points would typically correspond to stars that can be easily identified on all images. After picking on a star, the actual point is automatically refined to find the central pixel of the star image. This auto-refinement will not work too well if the star is over-exposed and covers a large number of pixels, so it is best to choose stars that are bright and identifiable, but do not have overly large pixel presence on the image.
Using the terminology used below in the Auto-alignment section, the single point alignment is a translation transformation, while the two point alignment is a euclidean transformation.
As discussed further below, manual alignment is a good first step for EEC Auto-Alignment. If manual alignment is being done for this purpose, then it can be done fairly quickly since only an approximate alignment is required for ECC, which will fine-tune the alignment. Be sure to use TIF file format to preserve the image quality through several save and load steps.
Automatic Image Alignment
Alignment of images is required when the image moves across the field of view of the camera. For astronomical photos, there are 2 main ways this can happen.
- Camera on a fixed tripod taking short exposure photos that does not not track the stars.
- Camera that is guided to track the stars on an equatorial mount, but the tracking is not precise.
For the first situation, the images will contain translation and rotation effects. For the second situation, translation will be the dominant effect.
An additional effect that occurs is distortion from within the lens. Objects on the side of the field of view will move different distance across the image compared to those in the center of the field of view. This phenomena is most obvious in wide angle camera lens, but is still troublesome in longer focus lens such as 105mm and 200mm lens. It is less of a problem in telescopes, and probably negligible in most cases. This type of distortion complicates image alignment and requires "warping" of the images to make them overlay.
There are two auto-alignment methods available under the "Auto Align" tab.
Enhanced Correlation Coefficient maximization method (ECC method).
The ECC method has are four modes of operation:
- Translation: An image is shifted (translated) in the x-axis and/or y-axis directions to obtain a second image.
- Euclidean: An image is a rotated and shifted to obtain the second image. When a square undergoes Euclidean transformation, the size does not change, parallel lines remain parallel, and right angles remain unchanged after transformation.
- Affine: An affine transform is a combination of rotation, translation, scale, and shear. When a square undergoes an Affine transformation, parallel lines remain parallel, but lines meeting at right angles no longer remain orthogonal.
- Homography: All the previous transforms are 2-D transforms. A homography transform can account for some 3D effects. A square when transformed using a Homography, it can change to any quadrilateral.
For photos taken with a regular un-guided camera lens, the lens distortion inherent in that lens will mean that both translation and euclidean transform are not the best options. For photos taken with a 105 mm lens, the Affine method seems to work best. ECC-Homography processing takes longer than the other 3 methods, and although gives good results, doesn't seem to offer any improvement over ECC-Affine.
There are 2 termination criteria for ECC. The Epsilon criteria is the probably the more important one, with default value at 10x E-5. Setting it too a smaller value (push the slider to the right) will make it work harder.
The threads slider for ECC specifies how many CPU threads will be used, and therefore how many images will be processed con-currently. Be careful pushing this to maximum, as it will use a lot of PC memory. On my PC with 32 Gb memory, the 4 thread option easily consumes 16 Gb of PC memory. So a PC with 16 Gb memory or less will struggle when using 4 threads. It's recommended to first do a test using several images and a single thread, whilst monitoring the PC memory, and determine what is best for your PC setup.
The threads option in the ECC processing is independent of the multi-threaded option that can be set in the Parameter menu, and ECC will always run as specified by the selection made here.
This works by identifying key-points on each image. One image is assigned as the reference image to which all the other images will compared to. The key-points between each image and the reference image are matched, and transform computed to shift each of the images to overlay the reference image.
The Akaze method imposes localized "warps" as required to make the images match. As such it can be considered to be able to apply more "severe" corrections, than can the ECC method.
There are a number of parameters for this method, but these are currently locked to values that seem to work best. A series of QC plots are generated during the processing showing the key-points, matching and an X and Y shift map.
The Akaze method works over a larger range of spatial movement between the images, than does the ECC method.
General Alignment Information
Both the Akaze and ECC require specification of a reference image. It is best that the reference image be an image that is in the middle of the motion of a series a images. This is particularly important for the ECC, which has a very limited spatial motion range over which the method is effective.
It is recommended to only use TIF format files. It can be seen that ECC reaches termination a lot quicker on TIF files, when compared to equivalent JPG files, implying the image degradation inherent in JPG compression is making the process more difficult. Note that TIF files derived from JPG files will have inherited the JPG degradation.
The best plan when using the ECC method, is to first perform manual alignment in the pre-processing / processing workflow (preferably 2-point, but 1-point should be OK). This will give images that are approximately aligned, but still with no distortion corrections imposed. Then run ECC on these pre-aligned images. The subsequent ECC will run quicker (ie, reach the termination criteria quicker) on these pre-aligned images, and all the images should be with-in it's narrower spatial operating range.
Input data for stacking can come from either the image (loaded data), auto-aligned or processed file lists. Four stacking options are available.
- Mean Stack. An average of all the checked image.
- Median Stack (not yet operational).
- Star-trail Stack. For making a single star-trail image from a sequence of short sequential exposures. See Star-trail stacking for some more details.
- Plane Stack. For stacking images of planes taking off near an airport, with camera fixed on a tripod and a blue cloudless sky. See Plane stacking for some more details.
The default processing option is to do all processing sequentially in a single CPU thread.
Some of the processing methods have been optimized to run multi-threaded. The multi-threaded option will be used if the this option is allowed in the Parameters menu. The multi-threaded version will run quicker than the default single thread.
Ssupport for utilizing Nvidia GPU graphics cards has been investigated as an option for speeding up the processing. Although this has been demonstrated to work well for some processing options on an Nvidia GTX 960 card, this option has not yet been made available due to the complexities in making the libraries for distribution and the very large size of the resulting distribution package.