mastrostack: a class to automatically align and stack astro-photography images
This class gets a list of images, and automatically determines bright stars as control points. These are followed along pictures, and used to build an affine transformation at constant scale (e.g. a rotation and translation). All images are then stacked. The images can be given as file names (may include wildcards), or matrices from e.g. imread, and support both RGB and gray images. As stars are used for the alignment, this method is suited for deep sky images, but not for planetary imaging.
ma = mastrostack;
start the user interface, without loading images (can be done afterwards)
ma = mastrostack(light, dark, flat)
loads light, dark (background) and flat (scope response) images, and label them.
Start with: ma=mastrostack;
Then press the Return key on the main interface. A Drop Files Here button appears in the lower left side. Drag and drop your Dark, Flat and Light images there. Images having 'dark' or 'flat' in their path/file name are marked as such automatically. You may alternatively use the File menu items.
Supported image formats include JPG, PNG, TIFF, FITS. If you have installed readraw, you may as well directly import RAW camera images. This is highly recommended, as it retains much more information from the camera shot than the generated JPEG images, which prooves to be essential for subtracting the Dark image (background), and revealing faint objects.
Preparing the Stacking
After importing the files, you should label them using the 'Image/Mark as...' menu items. You can navigate within images with the Image/Goto menu item, and the arrow keys, or the mouse wheel. 'Bad' images can be skipped (ignored). To use them back, set their type to 'light'. You should then compute the master Dark and Flat images (Compute menu).
It is recommended to zoom onto specific features (e.g. a set of stars) to check visually for their sharpness. Deselect the Zoom tool, and scan through images using the left arrow key, and press the 'I' key to mark images to be ignored, such as those blurred. To reset the plot, press the Return key.
You can select the Reference image, which will be used as template for stacking. If not defined, the first image in the list will be used as such when stacking.
When ready, use the Compute/Stack menu item. If the Alignment has not been executed previously, it is achieved for each image. The final image is then shown and written to disk. Use e.g. Lightroom, RawTherapee, DarkTable to enhance contrast.
If you have difficulties in stacking (some images do not have enough control points), relax e.g. the translation tolerance, using the menu item 'Compute/Set tolerances'. You can also increase the number of control points. In case the main interface is closed, get it back with: plot(ma)
Using commands (scripting)
% create Ma(e)stroStack and import images
ma=mastrostack('path/to/images/*.JPG','path/to/darks/*.JPG','path/to/flats/*.JPG'); % stack. The first 'light' image will be used as Reference for stacking
(c) E. Farhi, 2018. GPL2.
correct method now removes hot spots (dead pixels)
Compatibility with Matlab > 2014b. Fix for hot/dead pixels and peak width.
Compatibility for Matlab > 2014b
much faster initial import. Improved sharpness selection tool.
Create scripts with code, output, and formatted text in a single executable document.