From: Nick Downing Date: Wed, 9 Feb 2022 11:28:22 +0000 (+1100) Subject: Redo high_five movie with correlate.py, do tank_battle movie with correlate.py, rough... X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?p=stop_motion.git;a=commitdiff_plain;h=15b00c5607fea76871c2c66cc7ea75913b9f9e0d Redo high_five movie with correlate.py, do tank_battle movie with correlate.py, roughly add men_at_work movie without post-production (just join all images) --- diff --git a/.gitignore b/.gitignore index fc30d27..7004d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ +*.png [a-z]*.jpg diff --git a/correlate.py b/correlate.py index 9162c67..d8ae5cc 100755 --- a/correlate.py +++ b/correlate.py @@ -96,7 +96,7 @@ def calc_match(normalized0, normalized1, xc, yc): max(yo - 1, 0):max(yo + 2, 0), max(xo - 21, 0):max(xo + 22, 0) ] = 0. - gamma.write_image(f'diag_{xc:d}_{yc:d}_corr.jpg', temp) + gamma.write_image(f'diag_{xc:d}_{yc:d}_corr.png', temp) if ( max_corr < EPSILON or xo < CUTOFF1 or @@ -130,7 +130,7 @@ def calc_match(normalized0, normalized1, xc, yc): max(y - 1, 0):max(y + 2, 0), max(x - 21, 0):max(x + 22, 0) ] = 0. - gamma.write_image(f'diag_{xc:d}_{yc:d}_match.jpg', temp) + gamma.write_image(f'diag_{xc:d}_{yc:d}_match.png', temp) diag0 = block0 + .5 diag0[ @@ -143,7 +143,7 @@ def calc_match(normalized0, normalized1, xc, yc): max(x - 21, 0):max(x + 22, 0), : ] = 0. - gamma.write_image(f'diag_{xc:d}_{yc:d}_block0.jpg', diag0) + gamma.write_image(f'diag_{xc:d}_{yc:d}_block0.png', diag0) diag1 = block10 + .5 diag1[ @@ -156,7 +156,7 @@ def calc_match(normalized0, normalized1, xc, yc): max(x - 21, 0):max(x + 22, 0), : ] = 0. - gamma.write_image(f'diag_{xc:d}_{yc:d}_block10.jpg', diag1) + gamma.write_image(f'diag_{xc:d}_{yc:d}_block10.png', diag1) x += xo y += yo @@ -171,7 +171,7 @@ def calc_match(normalized0, normalized1, xc, yc): max(x - 21, 0):max(x + 22, 0), : ] = 0. - gamma.write_image(f'diag_{xc:d}_{yc:d}_block11.jpg', diag1) + gamma.write_image(f'diag_{xc:d}_{yc:d}_block11.png', diag1) # return offset and feature relative to block centre return xo - XS, yo - YS, xf - XM // 2, yf - YM // 2 @@ -202,14 +202,14 @@ files = [ ] # first file is special as no transformation needs to be done -in_jpg, out_jpg = files[0] +in_png, out_png = files[0] -print(f'read {in_jpg:s}') -image0 = gamma.read_image(in_jpg) +print(f'read {in_png:s}') +image0 = gamma.read_image(in_png) shape = image0.shape -sys.stderr.write(f'write {out_jpg:s}\n') -gamma.write_image(out_jpg, image0) +sys.stderr.write(f'write {out_png:s}\n') +gamma.write_image(out_png, image0) ys, xs, cs = shape xb = (xs - XM - 2 * XS) // XP // 2 @@ -219,21 +219,21 @@ print('xb', xb, 'yb', yb) print('normalize') normalized0 = normalize(image0) if diag: - gamma.write_image('normalized0.jpg', normalized0 + .5) + gamma.write_image('normalized0.png', normalized0 + .5) # loop through remaining files comparing each to the previous cumulative_A = numpy.identity(3, numpy.double) for file in range(1, len(files)): - in_jpg, out_jpg = files[file] + in_png, out_png = files[file] - print(f'read {in_jpg:s}') - image1 = gamma.read_image(in_jpg) + print(f'read {in_png:s}') + image1 = gamma.read_image(in_png) assert image1.shape == shape print('normalize') normalized1 = normalize(image1) if diag: - gamma.write_image(f'normalized{file:d}.jpg', normalized1 + .5) + gamma.write_image(f'normalized{file:d}.png', normalized1 + .5) print('find corner candidates') p_all = [] @@ -351,14 +351,14 @@ for file in range(1, len(files)): max(xf1 - 21, 0):max(xf1 + 22, 0), : ] = 0. - gamma.write_image(f'diag_file{file:d}_0.jpg', diag0) - gamma.write_image(f'diag_file{file:d}_1.jpg', diag1) + gamma.write_image(f'diag_file{file:d}_0.png', diag0) + gamma.write_image(f'diag_file{file:d}_1.png', diag1) print('remap') out_image1 = perspective.remap_image(cumulative_A, image1) - sys.stderr.write(f'write {out_jpg:s}\n') - gamma.write_image(out_jpg, out_image1) + sys.stderr.write(f'write {out_png:s}\n') + gamma.write_image(out_png, out_image1) image0 = image1 normalized0 = normalized1 diff --git a/down.sh b/down.sh new file mode 100755 index 0000000..c917abe --- /dev/null +++ b/down.sh @@ -0,0 +1,6 @@ +#!/bin/sh +for i in IMG_*.jpg +do + j=`echo $i |sed -e 's/^IMG_\(.*\)\.jpg$/down_\1.png/'` + convert $i -resize 2145x1428 -type TrueColorMatte $j +done diff --git a/gamma.py b/gamma.py index 0fa7177..a0717d6 100755 --- a/gamma.py +++ b/gamma.py @@ -6,11 +6,12 @@ import numpy def read_image(in_file): # read double image image = imageio.imread(in_file) / 255. - + # gamma decode - linear = image < .0031308 * 12.92 - image[linear] /= 12.92 - image[~linear] = ((image[~linear] + .055) / 1.055) ** 2.4 + temp = image if len(image.shape) == 2 else image[:, :, :3] # skip alpha + linear = temp < .0031308 * 12.92 + temp[linear] /= 12.92 + temp[~linear] = ((temp[~linear] + .055) / 1.055) ** 2.4 return image @@ -18,9 +19,10 @@ def write_image(out_file, image): image = numpy.copy(image) # gamma encode - linear = image < .0031308 - image[linear] *= 12.92 - image[~linear] = 1.055 * image[~linear] ** (1. / 2.4) - .055 + temp = image if len(image.shape) == 2 else image[:, :, :3] # skip alpha + linear = temp < .0031308 + temp[linear] *= 12.92 + temp[~linear] = 1.055 * temp[~linear] ** (1. / 2.4) - .055 # write double image image[image < 0.] = 0. diff --git a/high_five/control00.txt b/high_five/control00.txt deleted file mode 100644 index 548d817..0000000 --- a/high_five/control00.txt +++ /dev/null @@ -1,28 +0,0 @@ -184,156 184,156 184,156 184,156 -.15,.15 .15,.15 .3,.3 .3,.3 -IMG_2336.jpg out0_2336.jpg 396,268 3964,420 628,1880 3856,1828 -IMG_2337.jpg out0_2337.jpg 360,268 3932,396 612,1888 3824,1796 -IMG_2338.jpg out0_2338.jpg 436,220 3996,368 668,1828 3888,1764 -IMG_2339.jpg out0_2339.jpg 412,212 3968,352 656,1824 3868,1736 -IMG_2340.jpg out0_2340.jpg 328,326 3900,456 584,1948 3792,1860 -IMG_2341.jpg out0_2341.jpg 392,288 3952,456 624,1916 3836,1860 -IMG_2342.jpg out0_2342.jpg 368,252 3952,440 620,1884 3836,1832 -IMG_2343.jpg out0_2343.jpg 396,304 3952,476 628,1928 3832,1876 -IMG_2344.jpg out0_2344.jpg 356,304 3920,444 604,1920 3812,1844 -IMG_2345.jpg out0_2345.jpg 392,296 3952,456 636,1912 3844,1844 -IMG_2346.jpg out0_2346.jpg 380,268 3956,424 636,1892 3844,1812 -IMG_2347.jpg out0_2347.jpg 380,304 3932,464 612,1924 3836,1852 -IMG_2348.jpg out0_2348.jpg 416,264 3976,428 648,1876 3864,1820 -IMG_2349.jpg out0_2349.jpg 404,292 3968,468 644,1908 3864,1856 -IMG_2350.jpg out0_2350.jpg 372,288 3936,424 628,1908 3844,1816 -IMG_2351.jpg out0_2351.jpg 416,272 3992,420 664,1888 3884,1816 -IMG_2352.jpg out0_2352.jpg 372,248 3948,420 624,1880 3848,1816 -IMG_2353.jpg out0_2353.jpg 428,300 3992,492 660,1924 3892,1876 -IMG_2355.jpg out0_2355.jpg 384,244 3956,396 636,1872 3852,1796 -IMG_2356.jpg out0_2356.jpg 372,256 3940,388 624,1872 3824,1796 -IMG_2357.jpg out0_2357.jpg 328,276 3920,388 588,1880 3824,1796 -IMG_2358.jpg out0_2358.jpg 404,240 3980,412 648,1856 3872,1820 -IMG_2359.jpg out0_2359.jpg 380,272 3956,436 628,1876 3852,1832 -IMG_2360.jpg out0_2360.jpg 372,292 3940,448 624,1908 3852,1832 -IMG_2361.jpg out0_2361.jpg 376,256 3940,408 624,1880 3852,1792 -IMG_2362.jpg out0_2362.jpg 320,320 3892,436 580,1928 3792,1836 diff --git a/high_five/control01.txt b/high_five/control01.txt deleted file mode 100644 index f444538..0000000 --- a/high_five/control01.txt +++ /dev/null @@ -1,28 +0,0 @@ -184,156 184,156 184,156 184,156 -0.15,0.15 0.15,0.15 0.3,0.3 0.3,0.3 -IMG_2336.jpg out0_2336.jpg 396,268 3964,420 628,1880 3856,1828 -IMG_2337.jpg out0_2337.jpg 357,279 3924,391 609,1884 3835,1798 -IMG_2338.jpg out0_2338.jpg 418,218 3988,369 666,1818 3896,1772 -IMG_2339.jpg out0_2339.jpg 394,217 3964,340 651,1813 3882,1744 -IMG_2340.jpg out0_2340.jpg 326,339 3882,446 587,1933 3809,1847 -IMG_2341.jpg out0_2341.jpg 385,303 3940,453 639,1894 3863,1850 -IMG_2342.jpg out0_2342.jpg 383,264 3942,432 637,1852 3866,1827 -IMG_2343.jpg out0_2343.jpg 377,325 3931,479 635,1915 3865,1876 -IMG_2344.jpg out0_2344.jpg 346,325 3902,444 614,1911 3846,1845 -IMG_2345.jpg out0_2345.jpg 387,310 3941,458 647,1895 3883,1858 -IMG_2346.jpg out0_2346.jpg 384,284 3941,421 649,1868 3888,1821 -IMG_2347.jpg out0_2347.jpg 370,325 3923,465 635,1909 3872,1868 -IMG_2348.jpg out0_2348.jpg 406,270 3964,424 668,1855 3913,1828 -IMG_2349.jpg out0_2349.jpg 402,311 3956,475 661,1896 3905,1879 -IMG_2350.jpg out0_2350.jpg 363,300 3921,418 633,1883 3882,1825 -IMG_2351.jpg out0_2351.jpg 417,289 3976,409 687,1871 3939,1819 -IMG_2352.jpg out0_2352.jpg 379,271 3936,413 644,1856 3896,1821 -IMG_2353.jpg out0_2353.jpg 425,320 3978,484 686,1907 3939,1895 -IMG_2355.jpg out0_2355.jpg 383,261 3941,398 653,1843 3907,1807 -IMG_2356.jpg out0_2356.jpg 372,269 3929,393 644,1852 3879,1808 -IMG_2357.jpg out0_2357.jpg 340,287 3896,386 617,1868 3854,1799 -IMG_2358.jpg out0_2358.jpg 409,253 3964,414 677,1834 3916,1823 -IMG_2359.jpg out0_2359.jpg 386,282 3938,432 656,1865 3896,1842 -IMG_2360.jpg out0_2360.jpg 379,301 3930,447 653,1886 3894,1857 -IMG_2361.jpg out0_2361.jpg 368,266 3933,405 656,1852 3904,1815 -IMG_2362.jpg out0_2362.jpg 308,326 3869,437 602,1914 3847,1847 diff --git a/high_five/control10.txt b/high_five/control10.txt deleted file mode 100644 index 85dc8f7..0000000 --- a/high_five/control10.txt +++ /dev/null @@ -1,28 +0,0 @@ -184,156 184,156 184,156 184,156 -.15,.15 .15,.15 .3,.3 .3,.3 -out0_2336.jpg out1_2336.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2337.jpg out1_2337.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2338.jpg out1_2338.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2339.jpg out1_2339.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2340.jpg out1_2340.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2341.jpg out1_2341.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2342.jpg out1_2342.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2343.jpg out1_2343.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2344.jpg out1_2344.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2345.jpg out1_2345.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2346.jpg out1_2346.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2347.jpg out1_2347.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2348.jpg out1_2348.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2349.jpg out1_2349.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2350.jpg out1_2350.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2351.jpg out1_2351.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2352.jpg out1_2352.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2353.jpg out1_2353.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2355.jpg out1_2355.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2356.jpg out1_2356.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2357.jpg out1_2357.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2358.jpg out1_2358.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2359.jpg out1_2359.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2360.jpg out1_2360.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2361.jpg out1_2361.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2362.jpg out1_2362.jpg 396,268 3964,420 628,1880 3856,1828 diff --git a/high_five/control11.txt b/high_five/control11.txt deleted file mode 100644 index 4536a2c..0000000 --- a/high_five/control11.txt +++ /dev/null @@ -1,28 +0,0 @@ -184,156 184,156 184,156 184,156 -0.15,0.15 0.15,0.15 0.3,0.3 0.3,0.3 -out0_2336.jpg out1_2336.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2337.jpg out1_2337.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2338.jpg out1_2338.jpg 396,268 3964,420 628,1880 3856,1828 -out0_2339.jpg out1_2339.jpg 397,268 3965,420 629,1880 3856,1828 -out0_2340.jpg out1_2340.jpg 396,267 3965,420 629,1880 3856,1829 -out0_2341.jpg out1_2341.jpg 396,266 3965,420 629,1880 3856,1829 -out0_2342.jpg out1_2342.jpg 396,266 3965,420 629,1880 3856,1828 -out0_2343.jpg out1_2343.jpg 396,266 3966,420 630,1880 3856,1828 -out0_2344.jpg out1_2344.jpg 396,266 3967,421 631,1880 3856,1828 -out0_2345.jpg out1_2345.jpg 396,266 3967,421 631,1880 3855,1828 -out0_2346.jpg out1_2346.jpg 397,266 3967,421 631,1880 3855,1828 -out0_2347.jpg out1_2347.jpg 397,265 3967,422 631,1880 3855,1828 -out0_2348.jpg out1_2348.jpg 397,265 3967,422 631,1880 3855,1828 -out0_2349.jpg out1_2349.jpg 397,265 3967,422 631,1880 3855,1828 -out0_2350.jpg out1_2350.jpg 397,265 3967,422 631,1880 3855,1828 -out0_2351.jpg out1_2351.jpg 397,265 3967,422 631,1880 3856,1827 -out0_2352.jpg out1_2352.jpg 397,268 3967,422 631,1880 3856,1827 -out0_2353.jpg out1_2353.jpg 397,268 3967,422 631,1881 3856,1827 -out0_2355.jpg out1_2355.jpg 397,268 3969,422 631,1881 3859,1827 -out0_2356.jpg out1_2356.jpg 397,268 3969,422 631,1881 3882,1823 -out0_2357.jpg out1_2357.jpg 397,267 3969,422 631,1881 3882,1825 -out0_2358.jpg out1_2358.jpg 397,267 3969,422 631,1881 3882,1826 -out0_2359.jpg out1_2359.jpg 397,267 3969,422 631,1881 3883,1827 -out0_2360.jpg out1_2360.jpg 397,267 3969,422 631,1881 3883,1828 -out0_2361.jpg out1_2361.jpg 400,266 3969,422 631,1881 3883,1829 -out0_2362.jpg out1_2362.jpg 400,266 3969,422 631,1881 3884,1829 diff --git a/high_five/down.sh b/high_five/down.sh deleted file mode 100755 index de045e2..0000000 --- a/high_five/down.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for i in out1_*.jpg -do - j=`echo $i |sed -e 's/out1/down/'` - convert $i -resize 2145x1428 $j -done diff --git a/high_five/encode.sh b/high_five/encode.sh deleted file mode 100755 index 6000aa4..0000000 --- a/high_five/encode.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ffmpeg -framerate 5 -pattern_type glob -i 'post_23*.jpg' -s 1366x768 -pix_fmt yuv420p -c:v libx264 post.mp4 diff --git a/high_five/high_five.mp4 b/high_five/high_five.mp4 new file mode 100644 index 0000000..9d92372 Binary files /dev/null and b/high_five/high_five.mp4 differ diff --git a/high_five/n.sh b/high_five/n.sh new file mode 100755 index 0000000..d5437e1 --- /dev/null +++ b/high_five/n.sh @@ -0,0 +1,9 @@ +#!/bin/sh +rm -f *.png +../down.sh +../correlate.py down_ out0_ +../correlate.py out0_ out1_ +../mean.py out1_*.png mean.png +# visually inspect mean.png and place clipping information in post.txt +../post.py