# Last edited on 2011-05-09 05:49:37 by stolfi UNPACKING Used two commands: ffmpeg -i video.m1v -ss 5 -t 6 -vcodec png frames/%08d.png Obtained 180 frames (00000001.png to 00000181.png). Deleted 67--92 and 102--110, too much camera motion blur. COMPOSITING Trying to align successive frames by hand. Let's pick some frames mkdir frames-p frames=( 0000000{1,2,3,4,5,6,7,8,9} ) for f in ${frames[@]} ; do bfile="frames-b/${f}.png" pfile="frames-p/${f}.ppm" convert ${bfile} ${pfile} done ( cd frames-p && display -title '%f' ${frames[@]/%/.ppm} ) & Created a file frames-p/points.txt with the pixel coords of 4 reference points fo each of those frames. Splittin that file into separate files frames-p/${f}.pts: ( cd frames-p && \ cat points.pts \ | gawk \ ' //{ n = $1; fn = (n ".pts"); printf "%s\n", substr($0,9) > fn; close(fn); } ' \ ) Checking the placement of the reference points: for f in ${frames[@]} ; do pfile="frames-p/${f}.ppm" ppts="frames-p/${f}.pts" ofile="frames-p/${f}-g.png" pt=( `cat ${ppts}` ) convert ${pfile} \ -stroke Yellow -fill None \ -draw "polygon ${pt[0]},${pt[1]} ${pt[2]},${pt[3]} ${pt[4]},${pt[5]} ${pt[6]},${pt[7]}" \ ${ofile} done ( cd frames-p && display -title '%f' ${frames[@]/%/-g.png} ) & Pick a reference frame ${ref} and apply a projective map correction to all frames to match is reference points: ref=00000005 rpts="frames-p/${ref}.pts" for f in ${frames[@]} ; do pfile="frames-p/${f}.ppm" ppts="frames-p/${f}.pts" ofile="frames-p/${f}-a.ppm" pnmprojmap \ -points `cat ${ppts}` `cat ${rpts}` \ -interpolate 0 \ -oSize 900 600 \ -oOrg 90 60 \ -maxval 65535 \ ${pfile} \ > ${ofile} done ( cd frames-p && display -title '%f' ${frames[@]/%/-a.ppm} ) & The alignments were not spectacular. I must write a multi-image alignment program that combines a projective map with a low-frequency harmonic series distortion. Let's try mixing the corrected images anyway: pnmxarith -mix 0.50000 0.50000 frames-p/00000001-a.ppm frames-p/00000002-a.ppm > .a12.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000003-a.ppm frames-p/00000004-a.ppm > .a34.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000005-a.ppm frames-p/00000006-a.ppm > .a56.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000007-a.ppm frames-p/00000008-a.ppm > .a78.ppm pnmxarith -mix 0.50000 0.50000 .a12.ppm .a34.ppm > .a1234.ppm pnmxarith -mix 0.50000 0.50000 .a56.ppm .a78.ppm > .a5678.ppm pnmxarith -mix 0.50000 0.50000 .a1234.ppm .a5678.ppm > .a12345678.ppm pnmxarith -mix 0.11111 0.88889 frames-p/00000009-a.ppm .a12345678.ppm > .atot.ppm convert .atot.ppm .atot.png gimp .atot.png & The result is not bad! Removing the low-frequency components with fft: pnmfftfilter -kill -from 120 -verbose .atot.ppm > .ahip.ppm convert .ahip.ppm frames-b/avg-001--009.png display frames-b/avg-001--009.png &