Ma(e)stroStack: align and stack images (class)

Ma(e)stroStack: a Matlab class to automatically align and stack astro-photography images
241 descargas
Actualizado 22 jul 2020

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.

Importing images

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.

More at <>
See also: <>

Citar como

Emmanuel Farhi (2024). Ma(e)stroStack: align and stack images (class) (, GitHub. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2010a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

No se pueden descargar versiones que utilicen la rama predeterminada de GitHub

Versión Publicado Notas de la versión

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.

added icon/image

Para consultar o notificar algún problema sobre este complemento de GitHub, visite el repositorio de GitHub.
Para consultar o notificar algún problema sobre este complemento de GitHub, visite el repositorio de GitHub.