Like most websites, SGL uses cookies in order to deliver a secure, personalised service, to provide social media functions and to analyse our traffic. Continued use of SGL indicates your acceptance of our cookie policy.

# 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
wimvb    1,901
Posted (edited)

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
Posted (edited)

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
wimvb    1,901

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

• By MikeODay
A new High Dynamic Range image of the Sculptor Galaxy ( NGC 253 ) captured over a number of nights in mid-September 2017 and processed with PixInsight using the DrizzleIntegration and PhotometricColorCalibration tools.

The Silver Coin or Sculptor Galaxy ( NGC 253 ) in the Sculptor constellation.
( please click / tap on image to see larger and sharper )
On the 23rd of September 1783, sitting before her telescope in the field behind the house she shared with her brother William at Datchet, near Slough in the south of England, Miss Caroline Herschel "swept" the sky searching for new comets and never before seen star clusters and nebulae.   On this occasion, way down in the sky, not far above the Southern horizon, in an area of the southern sky that Nicolas de Lacaille had called the “Apparatus Sculptoris” or “the sculptor’s studio", Miss Herschel saw and noted down a very bright and large nebula where one had never before been recorded.  This event was later recognised by her brother, Sir William Herschel, as the discovery, by Caroline Herschel, of the nebula he listed in his catalogue as H V.1.   In later years, her 'beloved nephew', Sir John Herschel, William's son, would record this 'nebula' as entry # 138 in his General Catalogue of Nebulae and Clusters of Stars ( eventually becoming the 253th entry in the New General Catalogue, NGC 253 ).
Whilst relatively close to us compared to the billions of far more distant galaxies in the Universe, the great size of the “Sculptor Galaxy” and the huge distances involved are still hard to comprehend.  To put this into some perspective, the light that is just now reaching one edge of the great disc left the opposite edge when the Earth was in the grip of last great Ice Age 70,000 years ago and the light we now see has been travelling towards us for over 11 million years.
........
More information on the discovery of the Sculptor Galaxy by Miss Caroline Herschel, as well as the later observations by both Sir William and Sir John Herschel, can be found in my  Stargazerslounge blog, “The Sculptor Galaxy ( NGC 253 )”
.........
This image was captured over a number of nights in the middle of September 2017 and processed on the 23rd; exactly 234 years from the day of its discovery by Caroline Herschel.
With over 18 hours of total exposure, this HDR image attempts to capture the huge range of brightness levels; from the brightest stars and the core of the galaxy through to the numerous 'tiny' galaxies scattered throughout the image ( the total magnitude range is from around mag 8.8, for the brightest star, to 22+ for the faintest stars and galaxies visible in the image).
Mike O'Day
......................
Capture Details:
Telescope:
Orion Optics CT12 Newtonian ( mirror 300mm, fl 1200mm, f4 )
Corrector: ASA 2" Coma Corrector Quattro 1.175x
Effective Focal Length / Aperture : 1410mm f4.7
Mount: Skywatcher EQ8
Guiding:
TSOAG9 Off-Axis-Guider, Starlight Xpress Lodestar X2, PHD2
Camera:Nikon D5300 (unmodified) (sensor 23.5 x 15.6mm, 6016x4016 3.9um pixels)
Location: Blue Mountains, Australia
Moderate light pollution ( pale green zone on darksitefinder.com map )..
Capture ( 16, 17, 19,20,22 Sept. 2017 )
8 sets of sub-images with exposure duration for each set doubling ( 2s to 240s ) all at ISO800
273 x 240s + 10 each @ 2s to 120s
total around 18hrs
Processing
Calibration: master bias, master flat and no darks.
Drizzle Integration in 8 sets.
HDR combination
PhotometricColorCalibration
Pixinsight & Photoshop
23 Sept. & 8 Oct 2017
Image Plate Solution ( this cropped image )
===============================================
Resolution ........ 1.324 arcsec/px
Rotation .......... -180.00 deg ( South ^, East > )
Field of view ..... 57' 57.5" x 38' 40.1"
Image center ...... RA: 00 47 32.809  Dec: -25 17 04.48
===============================================
....................
Designations and alternative names for the Sculptor Galaxy:

CH10  ( Caroline Herschel # 10 )
H V.1  ( William Herschel,  Class V ( very large Nebulae ) # 1  )
H 61, H 2345  ( John Herschel observations identifiers )
GC 138.   ( John Herschel’s - A General Catalogue of Nebulae and Clusters of Stars # 138 )
NGC 253  ( John Herschel’s catalogue updated by Dreyer - The New General Catalogue of Nebulae and Clusters of Stars # 253 )
Caldwell 65
Leda 2789
ESO 479-29
Sculptor Galaxy
Silver Coin Galaxy
Silver Dollar Galaxy
..................

Annotated image of the Sculptor Galaxy ( NGC 253 ) - showing the brighter stars ( from the Tycho-2 catalogue ) as well the galaxies recorded in the Principal Galaxies Catalogue ( PGC ).  I have yet to complete identifying and annotating the very large number of ‘tiny’ galaxies in the image.
( please click / tap on image to see larger and sharper )

.........
• By jdmgray
Hi everyone.
I'm currently running Linux on my laptop and just wanted to know the best stacking software is for an amateur to use.
I tried installing registax with wine but it didn't work.
I've tried out PIPP and didn't really get on with it.
So far the only one I've gotten my head around is Siril by free astro.
Would like to know what other software there is that works well on linux that is good for amateurs who have just started playing around with this.

• I had a pretty successful session last night capturing 390 x 10 sec subs of asteroid Florence through patchy thin cloud with my Atik 460EX camera
I want to now turn these into an animation.  My thought is to convert the FITS files into TIFF files, align them, batch process them in Photoshop or Lightroom, then convert the resulting aligned, processed TIFF files into an animation.
Is there software that will automatically align (but not stack) FITS files and save the aligned subs as TIFF files?  If not, what is the best way of batch converting 390 x FITS files to TIFFs?
Thanks

• By MikeODay
( Edit 20 Aug: adjusted to increase brightness )
...
The Fighting Dragons of Ara ( NGC 6188 )

( please click/tap on image to see larger and sharper )

......................
Original:
The Fighting Dragons of Ara ( NGC 6188 )

( please click/tap on image to see larger and sharper )
Bright Nebula NGC 6188 and open cluster NGC 6193 are embedded 4,300 light years away in the Sagittarius arm of our Milky Way galaxy and can be seen with the naked eye south of Scorpius in the constellation of Ara.
With powerful stellar winds and energetic ultra-violet radiation, massive stars sculpt the interstellar gas and dust of the nebula into wonderful shapes and cause the interstellar gas to brightly fluoresce.
Closer to the hot young stars of the cluster, bright blue “sunlight” reflects off the clouds of gas and dust to produce the blue reflection nebulae seenin the image.
Magnitude +5.19, RA 16h 41m 42s, Dec -48deg 48' 46".
Approx. 3800 light years away.
Image details:
Plate Solution:
Resolution .......0.586 arcsec/px ( original full size image ).
Rotation .......... 89.764 deg.
Pixel size ........ 3.90 um.
Field of view ..... 58' 41.6" x 39' 9.5".
Image center ...... RA: 16 40 09.856  Dec: -48 41 22.50.
Image bounds:.
top-left ....... RA: 16 42 10.059  Dec: -49 10 30.54.
top-right ...... RA: 16 42 06.489  Dec: -48 11 57.14.
bottom-left .... RA: 16 38 11.010  Dec: -49 10 39.74.
bottom-right ... RA: 16 38 11.897  Dec: -48 12 05.58.
Telescope:
Orion Optics CT12 Newtonian ( mirror 300mm, fl 1200mm, f4 ).
Corrector: ASA 2" Coma Corrector Quattro 1.175x.
Effective Focal Length / Aperture : 1410mm f4.7.
Mount: Skywatcher AZ Eq6 GT.
Guiding: TSOAG9 Off-Axis-Guider, Starlight Xpress Lodestar X2, PHD2 .
Camera:
Nikon D5300 (unmodified) (sensor 23.5 x 15.6mm, 6016x4016 3.9um pixels).
Location:
Blue Mountains, Australia
Moderate light pollution ( pale green zone on darksitefinder.com map ).
Capture ( 24 June 2017 ).
12 sets of sub-images with exposure duration for each set doubling ( 1/8s to 240s ) all at ISO800.
34 x 240s + 10 each @ 1/8s to 120s.
Processing ( Pixinsight - 19 Aug 2017  ).
Calibration: master bias, master flat and no darks.
Integration in 12 sets.
HDR combination
PhotometricColorCalibration.

×

• #### Resources

• Code of Conduct