Image Stacking: Mean and Median Stacks for Noise, Crowds and Long Exposures

A night sky full of stars over a meadow, with the exposed roots of a fallen tree in the foreground
Photo: Perseid Meteor Shower over a Tree's Elevated Roots by Duncan Rawlinson. 24mm, f/2.8, 30s, ISO 3200. A 30 second frame at ISO 3200, the kind of noisy single exposure that stacking several frames cleans up.

Image stacking means shooting several frames of the same scene, lining them up, and combining every pixel with a statistic. A mean (average) stack cuts random noise by the square root of the frame count, so 4 frames halve it. A median stack keeps only what stays still, so people walking through a landmark vanish. A mean stack of a burst also imitates a long exposure without a filter.

One idea, three uses

Every stack works the same way. You take a pile of frames that show the same scene from the same position. For each pixel location, the software looks down through the pile at the values that pixel has in every frame, then writes one value into the result. The only decision is which statistic it uses to pick that value.

  • Mean (average): adds the values and divides by the number of frames. Anything that is the same in every frame stays. Anything random, like sensor noise, partly cancels out. Anything that moves gets smeared into a blur, which is exactly what a long exposure does.
  • Median: sorts the values and takes the middle one. If a person stands on a pixel in 3 frames out of 15, the 3 odd values sit at one end of the sorted list and the middle value is the empty pavement. The person disappears completely rather than turning into a ghost.

So the three common uses are really two statistics. Noise reduction and long exposure simulation are both a mean stack. Crowd removal is a median stack. Once that clicks, choosing a mode becomes obvious: ask whether you want moving things blended in (mean) or thrown out (median).

Stacking for depth of field is a different process with the same name. It blends the sharpest parts of frames focused at different distances, and it is taught in focus stacking. Combining different exposures to hold highlights and shadows is exposure blending or HDR. This page is about frames that are all exposed and focused the same way.

Why averaging cuts noise: the square root rule

Noise is random variation. In one frame a pixel that should read 100 might read 104; in the next, 97; in the next, 101. The true value is the same each time, but the error points a different way each time. Averaging keeps the true value and lets the errors partly cancel.

They do not cancel in a straight line. Random errors shrink with the square root of the number of frames. Four frames give half the noise, not a quarter. Sixteen frames give a quarter of the noise. To halve the noise again you always need four times as many frames.

Frames averaged Noise left Noise cut by Same as gaining
1 100% 1x 0 stops
2 71% 1.4x 1 stop
4 50% 2x 2 stops
8 35% 2.8x 3 stops
16 25% 4x 4 stops
32 18% 5.7x 5 stops

The last column is the useful one. Averaging 4 frames collects 4 times the light in total, which is 2 stops, so the result has roughly the noise of a single frame shot with 2 stops more light. Four frames at ISO 6400 land close to one frame at ISO 1600. Sixteen frames at ISO 6400 land close to ISO 400. Each doubling of the frame count is worth about one stop.

The table also shows why returns fall off. Going from 1 to 4 frames removes half the noise. Going from 16 to 32 frames takes you from 25% to 18%, a change many people would struggle to see at normal viewing size. For most handheld noise stacks, 4 to 8 frames is the sweet spot. Night sky work, where every bit of shadow detail counts, often uses dozens, which is why it gets its own process in astrophotography.

What averaging does not fix

The square root rule only applies to noise that changes from frame to frame. Two kinds of error do not:

  • Fixed pattern noise, such as hot pixels, banding and amp glow, sits in the same place in every frame. Averaging leaves it untouched. A median stack of frames with a slight shift between them can remove hot pixels, because the hot pixel lands on different scene detail each time and gets voted out.
  • Clipped highlights are clipped in every frame. Stacking reduces noise in the shadows and midtones; it does not recover a blown sky. Expose so the highlights are safe and let the stack clean the shadows. The histogram tells you where you stand.

For what the different kinds of grain look like and where they come from, see camera noise and luminance noise.

Why the median removes crowds

Picture one pixel on the steps of a busy building across 15 frames shot a few seconds apart. In 11 frames the pixel shows grey stone. In 4 frames someone is standing there: a red coat, a blue backpack, a dark shoe, a pale shirt. Sort those 15 values from darkest to brightest and the middle one, the 8th, is grey stone, because stone takes up 11 of the 15 places.

That is the whole trick, and it gives you the rule for how many frames you need: at every pixel, the background must be visible in more than half the frames. If a person stands on a spot in 8 of 15 frames, the median picks the person and you get a sharp, half-faded figure or a smudge. If they stand there in 4, they vanish completely.

So the length of time you shoot over matters more than the frame count. People who keep walking clear a spot within seconds. People who sit on a bench, queue at a ticket desk or pose for photos can stay put for minutes. Practical starting points:

  • Steady stream of walkers: 15 frames, one every 3 to 5 seconds, covering about 45 to 75 seconds.
  • Mixed walkers and loiterers: 20 to 30 frames, one every 5 to 10 seconds, covering 2 to 5 minutes.
  • Packed square where nobody leaves: the median cannot help; there is no frame where the ground shows. Come back at a quieter hour or plan to paint out the stubborn people by hand from individual frames.

An odd number of frames gives a single true middle value. With an even number the software averages the two middle values, which is usually fine but can leave a faint trace where a crowd was almost at the half way point.

Timing and location tips for the shoot itself, such as arriving early and choosing angles that hide queues, are in photographing crowded landmarks. This page covers the stacking side.

What the median does to things that should stay

The median removes anything that moves, not just people. Clouds that drift become a smooth average sky or a patchy one. Flags, trees in wind and water lose their texture or come out blotchy, because each pixel picks its middle value independently of its neighbours. Shadows move too if you shoot over a long time. The usual fix is to stack, then use a layer mask to bring back the sky, water or trees from one good single frame. Layers and masks covers that blending.

Faking a long exposure with a burst

A long exposure blurs moving water and clouds because the sensor records many moments added together. A mean stack does the same thing after the fact. Twenty frames at 1/8 s averaged together look a lot like one exposure of 2.5 seconds (20 x 1/8 = 2.5), and they need no ND filter.

The equivalence in stops follows the same doubling logic. Averaging 32 frames multiplies your total exposure time by 32, which is 5 stops. Averaging 64 is 6 stops. A 6 stop result would otherwise need an ND filter rated at 6 stops.

There is one real difference. A single long exposure records continuously. A burst has gaps between frames while the camera reads out and resets. With slow things, like clouds or a calm sea, the gaps vanish into the average. With fast things, like a waterfall or car lights, each frame captures a separate slice and you can see stepping: water looks like layered strands rather than silk. The fixes:

  • Use the slowest shutter speed the light allows for each frame, so each slice is already blurred and the slices overlap.
  • Use a fast continuous burst with as little gap as possible. See burst mode for how frame rate and buffer interact.
  • Shoot more frames over the same span rather than fewer frames over a longer span.

A bonus: because this is a mean stack, the result is also cleaner than any single frame. A long exposure built from 32 frames has about 5.7 times less random noise than one of its frames. The older version of this technique, built from interval shots, is shown step by step in using timelapse photos to make a long exposure.

Shooting frames that stack well

Every stack needs frames that are identical in everything except the thing you want to change. That means locking the camera down, either literally or in its settings.

Camera settings

  • Manual exposure. Auto modes can change the exposure between frames as people walk through, which leaves blotches in the median result.
  • Manual or locked focus. Refocusing between frames changes the image scale slightly and causes soft edges after alignment.
  • Fixed white balance. Auto white balance can shift the colour from frame to frame.
  • Raw files. Stacking works on the full tonal range, and you can apply the same raw settings to every frame before stacking. Raw explains why that headroom matters.
  • Image stabilisation off on a tripod, on when handheld. Follow your lens or camera guidance here, since some systems handle tripods automatically.

Tripod or handheld

A tripod is the easy route. The frames line up almost perfectly, alignment barely has to work, and you can shoot as slowly as the scene needs. How to use a tripod covers keeping it rock still, and an intervalometer or the camera’s built in interval timer fires the frames at a set spacing so you do not touch the camera.

Handheld stacking works well for noise reduction and reasonably well for crowd removal. Hold as still as you can, shoot a burst, and let the software align the frames. Expect to lose a little at the edges, because the frames do not overlap there, so frame slightly wider than you want. Keep each frame sharp; stacking reduces noise but it averages camera shake into general softness rather than removing it.

Combining the frames

The steps are the same in any layered editor or dedicated stacking program:

  1. Process the raw files identically. Apply the same white balance, exposure and lens corrections to every frame. Keep noise reduction and sharpening low or off; the stack does the noise work, and sharpening afterward works better on the cleaner result.
  2. Export as 16 bit files. 16 bit TIFF keeps the extra tonal precision the stack creates. Bit depth explains why 8 bit can band in smooth skies.
  3. Load all frames as layers in one document. In Photoshop, File, Scripts, Load Files into Stack does this and offers to align the layers automatically.
  4. Align. Automatic alignment matches the frames even when handheld. Check a few edges at 100% to make sure nothing is doubled.
  5. Convert to a single combined layer and choose the statistic. In Photoshop, turn the layers into a Smart Object, then pick Layer, Smart Objects, Stack Mode, and choose Mean or Median. Other editors and free stacking tools offer the same two modes under similar names.
  6. Repair and finish. Mask in any parts that stacked badly from a single frame, then sharpen and edit as normal.

Common mistakes with image stacking

  • Expecting 2 frames to halve the noise. Two frames cut noise by about 29%, not 50%. Halving needs 4. Plan the frame count from the square root rule.
  • Shooting crowd frames too close together. Fifteen frames in 3 seconds is one moment repeated; everyone is still standing in the same place. Spread the frames over time so each spot is clear in most of them.
  • Leaving exposure on auto. Changing exposure between frames creates patches in the result where different frames won the vote.
  • Using the median for noise. The median does reduce noise, but less efficiently than the mean, needing more frames for the same result. Use the mean for noise and the median when something must be thrown out.
  • Using the mean for crowds. A mean stack turns people into faint translucent ghosts rather than removing them. If someone is still visible as a ghost, switch to median.
  • Heavy noise reduction before stacking. Smoothing each frame first throws away fine detail that the stack would have kept. Let the stack work first, then decide whether you need more. Noise reduction covers how to apply it gently afterward.
  • Ignoring the water and sky. Median results often leave water and clouds blotchy. Check them at 100% and mask in a single frame where needed.

Try this: a 10 minute noise and crowd test

You need a camera or a phone that can lock exposure, and somewhere with a few people passing by, such as a shop front, a station entrance or a park path.

  1. Set the highest ISO you would normally avoid, so noise is easy to see. On a phone, use a pro or manual mode and lock exposure and focus.
  2. Brace the camera on a wall, a bench or a tripod so it does not move.
  3. Take 16 frames, one every 4 seconds, which takes just over a minute. Do not touch the framing.
  4. Back at the computer, make three stacks: a mean of the first 4 frames, a mean of all 16, and a median of all 16.
  5. Compare a dark area of a single frame with the two mean stacks at 100%.

How to judge the result: the 4 frame mean should look visibly smoother than the single frame, and the 16 frame mean smoother again, but by a smaller step, which is the square root rule in action. In the median stack, people who kept walking should be gone. Anyone left behind, or left as a smudge, was standing in one spot for more than half the frames.

Image stacking FAQ

How many photos do I need to remove tourists?

Fifteen to twenty frames spread over a minute or two works for most scenes where people keep moving. The real requirement is that every spot is clear of people in more than half the frames, so slow moving crowds need a longer time span rather than simply more frames.

Can I stack photos taken handheld?

Yes. Automatic alignment lines up handheld frames well, as long as each frame is sharp and you hold the camera at roughly the same position. Frame a little wider than you need, because the edges get cropped after alignment.

Is stacking better than noise reduction software?

They solve the problem in different ways. Stacking collects more real light, so it reduces noise without inventing or smoothing away detail; software estimates what is noise and removes it from one frame. Stacking needs a static scene and several frames, while AI noise reduction works on a single shot, and the two can be combined.

Does stacking work with moving subjects?

Not for the moving parts. A mean stack blurs them and a median stack removes them, which is what you want for crowds and water but not for a person you meant to photograph. For a portrait or wildlife subject, use a single frame for the subject and mask it over a stacked background.

Why does my median stack still show faint people?

Those people stood in the same place for close to half the frames or more. Shoot over a longer time, add frames, or paint the area back in by hand from one frame where that spot was empty.

Is a stacked long exposure the same as using an ND filter?

Close, but not identical. A filter records continuously, while a burst has short gaps between frames, which can show as stepping on fast motion such as waterfalls. For slow motion like clouds and calm water the results look very similar, and the stack is cleaner.

Wondering what ISO to set when you plan to stack anyway? See how ISO affects noise in a single frame.

Want silky water from a single shot instead? How to photograph waterfalls covers the shutter speeds.

Need to clear just one or two people rather than a whole crowd? Try removing objects in Photoshop.

Curious how stacking frames can add resolution as well as cut noise? Read about superresolution in Photoshop.

Shooting a long exposure the traditional way? Long exposure explains filters, timing and what to blur.