# Last edited on 2011-04-30 04:32:08 by stolfi UNPACKING Used two commands: ffmpeg -i video.mpg frames-a/%08d.jpg ffmpeg -i video.mpg -vcodec png frames-b/%08d.png Obtained 196 frames. Deleted frames 00000001 through 00000037 and 00000154 through 00000196 (camera out of water). COMPARING Comparing the two results: convert frames-a/00000130.jpg .a.ppm convert frames-b/00000130.png .b.ppm pnmxarith -subtract -scale 10 -offset 0.5 .a.ppm .b.ppm > .diff.ppm display .diff.ppm There is a difference, it seems. Trying to compare visually: display -filter box -resize '200%' .a.ppm .b.ppm & The frames-b output looks better; the frames-a has visible 8x8 JPEG blockiness. Whether it is more accurate, or just smoothed out, I do not know. Anyway: rm -rf frames-a COMPOSITING Trying to align successive frames by hand. Let's pick some frames from the middle of the movie mkdir frames-p frames=( 0000009{0,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 for each frame ${f} a file frames-p/${f}.pts containing the pixel coords of 4 referece points. Pick a reference frame ${ref} and apply a projective map correction to all frames to match is reference points: ref=00000095 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 so good, because (1) the ref points were not very accurate, (2) the second reference point may not be coplanar with the other three (which lie at the top of the fuel assemblies), and, mainly, (3) there is much image deformation by thermal gradients in the water. 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/00000090-a.ppm frames-p/00000091-a.ppm > .a01.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000092-a.ppm frames-p/00000093-a.ppm > .a23.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000095-a.ppm frames-p/00000096-a.ppm > .a56.ppm pnmxarith -mix 0.50000 0.50000 frames-p/00000097-a.ppm frames-p/00000098-a.ppm > .a78.ppm pnmxarith -mix 0.66667 0.33333 .a23.ppm frames-p/00000094-a.ppm > .a234.ppm pnmxarith -mix 0.66667 0.33333 .a78.ppm frames-p/00000099-a.ppm > .a789.ppm pnmxarith -mix 0.40000 0.60000 .a01.ppm .a234.ppm > .a01234.ppm pnmxarith -mix 0.50000 0.50000 .a56.ppm .a789.ppm > .a56789.ppm pnmxarith -mix 0.50000 0.50000 .a01234.ppm .a56789.ppm > .atot.ppm convert .atot.ppm .atot.png gimp .atot.png & The result is not bad! Adjusted channel curves with gimp, cropped and saved as "frames-b/avg-090-099-c.png"