# Algorithm to stack astronomical images

## Recommended Posts

I'm looking for a simple algorithm to compare astronomical images (of the same sky region) against each other, compute their movement and rotation, to finally stack them.

At the moment I'm already having a more or less working algorithm. First I extract all the stars out of an image (including information like brightness and FWHM), and then I walk trough all the resulting "points" and create triangles out of the current point and those two other stars that have the shortest distance to this star.

This list of triangles is created for every image. After this I take one image as reference and then I walk through the list of triangles in the reference image to find a triangle in the other image with the same length of each side of the triangle (I also "allow" some tolerance due minimal relative differences of the star positions in each image). For this matches I calculate movement and rotation relative to the reference image. Last step is to find the matched triangles that have to same relative movement and rotation like the other matches. This is done by calculating the standard deviation, sorting out triangles that are not within 1 or 2 sigma and repeat this process until I have a very small standard deviation.

The last part, finding "valid" triangles with the same movement/rotation, is working fine. The problem is that sometimes I have only like 2 or 3 "valid" triangles out of 300 initial triangles. All other triangles have side lengths different to those of the reference image.

So I assume it's the way I generate my initial triangles which causes the problem. Sortings stars by their brightness and using this data to generate the triangles also doesn't work. So is there a better way to create the initial triangles in all the images?

Clear Skies,

David

##### Share on other sites

Aren't you reinventing the wheel?

This is what stacking/alignment algorithms already do.

Have you tried searching for scientific articles on the matter? (Not necessarily astro related). Juan Conejero if Pleiades Astrophoto wrote about this. His article is burried somewhere in the PixInsight web site / forum. Most likely the latter, in the section about new updates and features.

Due to minor geometrical defects (field curvature) of the optical system, stacking involves geometrical stretching of the images, to get the triangles to fit.

This is one reason why dss users sometimes complain of 'weird behaviour' in the corners of an image.

Good luck.

Edited by wimvb
##### Share on other sites

Yeah I know that there are already programs. I just want to write my own one as some "small" free time project. I know that there is some distortion on the edge of the images. That's the reason why a create triangles out of nearby stars and allow some tolerance in the side length of those triangles.

Pixinsight uses the RANSAC algorithm, however I use a different approach. In general my version also achieves good results - see the attached image - but it has some flaws building the initial "lookup structure". And I guess that's only a questions of how to select the stars per triangle. There are a lot of papers out there, but most of them are not within my free time schedule. - Like it said, I guess I just need some hint on which stars I should create my triangle. I have the following data of each star: position, FWHM on x and y axis and maximum brightness (but I could also calculate average brightness over occluded pixels). The question is how to use this wisely.

Edited by Hellstorm
##### Share on other sites

PixInsight has a tool to calculate the point spread function of stars. When using this tool it is recommended to exclude too bright (obviously) and too dim stars. Do you do something similar in your process? Probably FWHM and brightness is a way to achieve the same.

(and THAT's really all I can think of)

Good luck with your project, and keep us informed on your results.

## Create an account

Register a new account

• ### Similar Content

• #### Imaging C2022 issues with stacking

By baggywrinkle,

• 219 views
• #### Astronomers in Lancashire

By YusufS,

• 19 replies
• 403 views
• #### stacking difference

By Anthonyexmouth,

• 6 replies
• 238 views
• #### Web-cams with an Astronomical Interest....

By Craney,

• 2 replies
• 190 views