---
title: A 10-Second Video Folded Into One Photo — The Math of Stacking 682 Frames
url: https://oosioo.com/en/p/10%EC%B4%88-%EC%98%81%EC%83%81%EC%9D%84-%EC%82%AC%EC%A7%84-%ED%95%9C-%EC%9E%A5%EC%9C%BC%EB%A1%9C-%EC%A0%91%EC%97%88%EB%8B%A4-682%EC%9E%A5%EC%9D%84-%EA%B2%B9%EC%B9%98%EB%8A%94-%EA%B3%84%EC%82%B0
date: 2026-09-09T11:04:59+00:00
author: SYSOP
summary: I wanted to turn a 10-second action-cam clip into a single photo. Just adding frames burns them white; averaging them turns everything gray. It took three wrong turns and 26 minutes. This time, unlike the previous installment, I could actually see where I'd gone wrong.
---
# A 10-Second Video Folded Into One Photo — The Math of Stacking 682 Frames

I've long enjoyed photography now and then, and one technique in the medium is multiple exposure — shooting several images onto a single frame of film to complete one photograph. In the digital era, the practice of layering several images together is described with terms like digital compositing or layer blending. Tools like Photoshop made it easy to create or edit these and show off some creativity.

Lately, shooting video has become so effortless that alongside still photos I find myself capturing a lot of highly dynamic footage. It occurred to me to try, via an AI "one-click" approach, gathering the trajectories or the many different moments within a video into a single unified image.

Most of my recent footage is shot on a DJI Osmo Pocket 4. I'd film a short clip and **wanted to fold the entire span of time it contained into a single frame.** Overlapping all the frames seemed like the way to do it — the question was how to build the overlap.

> I want to take the frames extracted from a long action-cam video and composite them using a mathematical technique, preventing brightness values from saturating while still retaining a good measure of color information, so it comes together as a single abstract photograph. Build a program that analyzes the footage frame by frame, adds them together appropriately into one image, and output a single photo from this video.

Three lines. Inside them are **two constraints**: "prevent saturation" and "retain color information." As it turned out, those two were the whole problem.

## Why Is Overlapping a Problem at All

Let's start with what happens if you simply add the frames together.

A pixel's brightness is a value between 0 and 1, with white at 1. Add two frames together and 0.6 + 0.5 becomes 1.1 — and there's nowhere to represent a value above 1, so it gets **clipped**. Add 682 frames and most of the frame exceeds 1, turning into plain white paper. That's "saturation."

So why not divide and average instead? That works. Nothing burns out. Instead, **everything blurs.**
The average of 682 frames becomes a gray haze that resembles none of the 682 frames. The trace of any bright moment gets diluted down to 1/682 of itself.

It can't saturate, and it can't blur either. The whole task came down to finding a formula that satisfied both conditions at once.

## What Came Out of It

One program, and a handful of photos. Photos first.

![Result of overlapping 682 frames from a 10-second clip. The trajectory sweeping across the office forms layered bands of teal and yellow.](/uploads/82f2c59f369bb1d1.webp =860)

This is 10 seconds of sweeping once across the office, left to right. The refrigerator, the microwave, the whiteboard, the monitor, the night view outside the window — they pass by in sequence. Those 10 seconds are all layered into one frame. The yellow band running downward is the trace of the ceiling's cable tray passing through; the teal is the fluorescent lights.

Same clip, same 682 frames — but change only the way they're overlapped, and the results diverge like this. First, a composite that keeps only the brightest moments.

![Composite retaining only the brightest moments. The outlines of the ceiling structure and cables remain as lines, resembling a technical drawing.](/uploads/9c89500340b81937.webp =860)

The outlines of objects remain as lines, giving it the look of a technical drawing. Next, one where everything is averaged evenly.

![Composite averaged evenly across all frames. The outlines dissolve, leaving something soft, as if smudged with a brush.](/uploads/8ab0f6befa3f79ff.webp =860)

It comes out looking smudged with a brush. All three are the same footage.

## How It Actually Worked

**I handled brightness and color separately.**

Brightness first. Since adding it straight burns out and averaging blurs it, I used something in between.
Each frame's brightness is **raised to some power, averaged, then that root is taken back.** Set the exponent to 1 and it's an ordinary average; raise it high and only the brightest value survives. A single number lets you slide continuously between "a smooth average" and "keep only the brightest."

No matter what exponent is used, **the final step is still dividing by the number of frames.** No matter how many frames you stack, the value never exceeds 1. Saturation isn't something you carefully avoid — it's **structurally impossible.** That resolved the first constraint in the request.

But once I built it this way and looked at the resulting image, it had come out close to a plain black-and-white image, which felt too flat to be interesting. Granted, a black-and-white photo can be compelling through strong contrast or structure, but I wanted the balanced background of time to come through with a bit more color.

## Where I Went Wrong

I got it wrong three times.

### 1. The First Result Was Color Noise

The first output looked something like TV static. This is exactly the kind of spot where you'd assume the formula was wrong.

But the cause wasn't the calculation — it was **saving the file.** The standard image library I was using didn't know how to write 16-bit-per-channel PNGs, and instead of telling me it couldn't, it silently misread the data as 8-bit and saved it as-is. The math had been fine the whole time.

**I pulled out a single frame and saved it on its own.** That one frame came out as a perfectly normal office photo. That meant the part reading the video was fine, leaving either the calculation or the saving as the culprit. I changed how the file was saved, and it was fixed.

A symptom looking frightening doesn't mean the cause is buried deep.

### 2. The Second Result Was Almost Pure White

This time it wasn't noise — just a flat, uniformly bright image. This is the case where the math is correct but no picture emerges.

Overlap 682 frames and the values **get pulled toward the middle.** Both dark and bright regions, mixed across many frames, get dragged toward the median. On top of that, this particular clip was mostly white wall and white refrigerator, so that median itself sat on the bright side.

So I added a step: "pull some portion of the darkest range down to black, and stretch the rest out." It's the same operation commonly used in photo editing. Except **I didn't let a person decide how much to stretch.** It measures the spread of the resulting brightness distribution and calculates automatically to hit a target, since different footage clusters by different amounts.

### 3. The Color Died to Gray

The first two were solved as soon as I fixed them. The third was different.

Brightness came out fine, but there was no color. The image was a gray haze with only the faintest tint of color. At first I tried **giving more weight to frames with higher saturation.** It improved a little. Only a little.

I got stuck here for quite a while. Pushing the weighting harder, boosting saturation, adding contrast — each only nudged things slightly, and it was still gray. **This wasn't a spot that tweaking parameters could fix.**

**The cause was that I was averaging the colors.**

Average red and teal, and you get gray. Average blue and yellow, and you also get gray. Opposing colors cancel each other out. As the camera sweeps across the office, every kind of color passes through a given point, and averaging them **inevitably** pulls the result toward achromatic gray. No matter how you weight it, as long as it's an average, this can't be avoided. Weighting could only soften the effect, not eliminate it.

So I changed the formula. I **split color into two separate things: direction and magnitude.**

- **Direction** (which color it is — red or blue) gets averaged. Like averaging the needles of a compass, only the direction is averaged.
- **Magnitude** (how intense it is) is calculated **separately**, using the same "raise to a power, then average" approach as brightness.

If the directions diverge, the representative direction just becomes less distinct — **the intensity doesn't drop.** Intensity was never something being averaged in the first place.

Here's the image that came out before the change — the result of averaging color directly.

![Composite with color averaged directly. Differing hues cancel each other out, leaving only a faint tint over a gray haze.](/uploads/d0d91d703f888b74.webp =860)

The first image at the top of this piece is the result of splitting direction from magnitude. Same clip, same 682 frames, same brightness processing — only the color-combining formula differs. Even though the subject — a white office under fluorescent light — has almost no saturation to begin with, the difference is still this large.

One more thing: when the resulting intensified color exceeds the range the screen can display, **the hue is left untouched and only the intensity is scaled down** to bring it back into range. Clipping red, green, and blue individually, as is often done, distorts the hue — but scaling down only the intensity preserves the color.

## Why One Sentence Was Enough

In the previous installment, working with Four Pillars fortune-telling, I wrote that **AI does well in fields where the rules have long since been settled.** The same holds here. Image compositing is a field built up over decades by photography and film, and everything used here is a technique that already has a name. From ways of compressing brightness into range, to color spaces matched to human vision, to how to handle color exceeding its range — none of it was newly invented. I only threaded together things that were already scattered about, toward a specific purpose.

But with the fortune-telling piece, mistakes weren't visible on the surface. A plausible-sounding sentence would come out, and I needed some separate way to check whether it was actually correct — so building that verification process took extra time.

**Photography is rather different.** Since it belongs to the realm of creation, right and wrong have to be defined arbitrarily. It's simply a matter of explaining things through different concepts or notions so that my intent comes through clearly.

Across writing, painting, sculpture, photography, and more, the use of AI for expression is exploding. Looking at exhibitions sometimes, I see pieces that would've been so much more interesting with a different concept behind them, and plenty of others where the artist's creativity is genuinely remarkable. Culture and the arts are, in fact, one of the most fascinating and exciting frontiers for applying AI.

## If You Want to Try This Yourself

What actually did the work in the request were just two phrases: "prevent brightness saturation" and "retain color information."

**Write down what you want to avoid, not what you want to build,** and the machine picks the method. If I'd said "make me a cool photo," it probably would have slapped on a few filters. Saying "don't let it burn out, don't let the color die" turned it into the task of finding a formula that satisfied both conditions at once.

One more thing. When tweaking parameters produces only incremental improvement, telling **where adjustment ends and a design problem begins** was still a job for a human. That's exactly where I got stuck for so long on the third problem. Instead of continually cranking up the weighting, I should have asked, "why does this fundamentally trend toward gray?"

## What It Can't Do

**If the subject has no color, none can be produced.** This isn't inventing color that isn't there — it's gathering scattered color without losing it. A white office under fluorescent light has almost no saturation to begin with. Subjects like neon signs, sunsets, markets, or car taillights are where this approach earns its keep.

**It doesn't stabilize shake.** If the camera moves, that movement is preserved directly as a trajectory. That was the intent this time, but if you'd mounted the camera on a tripod and filmed only the subject moving, even the faintest camera shake would remain in the result too.

**How you shoot often matters more than the algorithm.** In particular, if white balance is left on automatic, the color temperature keeps shifting as the camera sweeps, and frames end up canceling each other out. That's the single most common reason color drains out of action-cam footage, and no amount of computation fixes it. The same goes for blown-out highlights — once a spot has turned pure white, no color information remains there to recover.

**Don't judge from a small preview.** To check things quickly, I tested by skipping to every fourth frame, and in that version the trajectory looked broken up like a dotted line. In the final version using every frame, it became a continuous band. Keep parameters small during testing, but **make the final judgment only after running it properly, in full.**

One more image to close with — color pushed less to the max, with spots where hues clash pulled down for a calmer result.

![Composite with clashing hues pulled down for a calmer result.](/uploads/80b2dc0c4765ff01.webp =860)

Which one is better comes down to taste. Getting to the point where **you can choose** was the whole point of this exercise.

Which photo from this series' work do you like best?

Can these images even really be called photographs?

Turning an interesting piece of footage into a photograph turned out to be great material for working with computers and AI, and the underlying knowledge was, surprisingly, already well organized — enough that I could quickly reach a satisfying result. If there's an application you find intriguing, or an image you particularly liked, let me know. I plan to try plenty more experiments like this.
That's all for today.
