Stacking: how many dim frames make one clear picture

Point a camera at a faint galaxy and every single exposure looks grainy. Part of that grain is the galaxy's own light arriving as a trickle of photons, part is the glow of the sky, and part comes from the camera itself. That grain is noise: random, different in every frame.
The light from the galaxy is not random. It lands on the same pixels in every frame. So if you take many frames and average them, the real light stays put while the random noise partly cancels out. This is stacking, and it is the most important trick in astrophotography.
The square root rule
Random noise does not vanish in a straight line. Averaging N frames lowers the noise by a factor of the square root of N, so the signal-to-noise ratio grows by the same factor:
- 4 frames: noise cut in half (the square root of 4 is 2).
- 16 frames: noise down to a quarter.
- 100 frames: noise down to a tenth.
That is why the gains slow down. Going from 1 to 16 frames is a huge jump; going from 100 to 116 barely shows. To halve the noise again you always need four times as many frames.
What else stacking fixes
Because the software compares the same pixel across many frames, it can spot values that do not fit, such as a satellite streak or an airplane crossing one frame, and leave them out. Astrophotographers also shoot calibration frames: darks (with the telescope covered, to measure the camera's own signal) and flats (of an evenly lit surface, to map dust and vignetting), and subtract or divide them out before stacking.
Try it
In the game's darkroom you hold a button to add frames to a stack and watch the noise melt. The counter shows the signal-to-noise gain, the square root of your frame count.
Triangulum Galaxy
Pinwheel Galaxy