Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dirty hack to fake long exposure from a quicktime movie
import os
import tempfile
import subprocess
import skimage
from skimage import exposure
import as io
import argparse
import shutil
import numpy as np
for movfile in os.listdir("./"):
if not movfile.lower().endswith(".mov"):
# movfile = "IMG_1318.MOV"
basechunk = os.path.splitext(movfile)[0]
# outdir = tempfile.mkdtemp()
outdir = basechunk
except OSError, e:
subprocess.check_call(["ffmpeg", "-i", movfile, os.path.join(outdir, "frame-%0d.png")])
coll = io.ImageCollection(
os.path.join(outdir, "frame-*.png"),
load_func=lambda f: io.imread(f).astype(np.float32))
# calculate an averaged frame
sumd = reduce(np.add, coll)
sumd = exposure.rescale_intensity(sumd)
io.imsave(basechunk+"_sum.png", sumd, )
# create a frame made up of all the brightest pixels
maxd = reduce(np.maximum, coll)
maxd = exposure.rescale_intensity(maxd)
io.imsave(basechunk+"_max.png", maxd, )
# Smush these two together in an arbitrary way to get some combination of brightness and detail
combd = sumd*3 + maxd
combd = exposure.rescale_intensity(combd)
io.imsave(basechunk+"_comb.png", combd, )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment