Smooth transition between MCs

A smooth transition of MotionClouds while smoothly changing their parameters.

In [1]:
#initialize
import os
import MotionClouds as mc
mc.N_frame = 128
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)

mc.figpath = '../files/2015-07-02_smooth'
if not(os.path.isdir(mc.figpath)): os.mkdir(mc.figpath)
In [2]:
import numpy as np

name = 'smooth'

name_ = mc.figpath + name

seed = 123456
B_sfs = [0.05, 0.1, 0.05] 
B_sfs = [0.025, 0.05, 0.1, 0.2, 0.4, 0.2, 0.1, 0.05]
im = np.empty(shape=(mc.N_X, mc.N_Y, 0))
name_ = name + '-B_sf'
for B_sf in B_sfs:
    im_new = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, B_sf=B_sf), seed=seed)
    im = np.concatenate((im, im_new), axis=-1)

mc.anim_save(mc.rectif(im), os.path.join(mc.figpath, name_))
mc.in_show_video(name_, figpath=mc.figpath)
In [3]:
name_ += '_and_smoother'
smooth = (ft - ft.min())/(ft.max() - ft.min()) # smoothly progress from 0. to 1.
N = len(B_sfs)
im =  np.empty(shape=(mc.N_X, mc.N_Y, 0))
for i_sf, B_sf in enumerate(B_sfs):
    im_old = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, B_sf=B_sf), seed=seed)
    im_new = mc.random_cloud(mc.envelope_gabor(fx, fy, ft, B_sf=B_sfs[(i_sf+1) % N]), seed=seed)
    im = np.concatenate((im, (1.-smooth)*im_old+smooth*im_new), axis=-1)

mc.anim_save(mc.rectif(im), os.path.join(mc.figpath, name_))
mc.in_show_video(name_, figpath=mc.figpath)

some book keeping for the notebook

In [4]:
%load_ext version_information
%version_information numpy, scipy, matplotlib, MotionClouds
Out[4]:
Software Version
Python 3.7.1 64bit [Clang 10.0.0 (clang-1000.11.45.5)]
IPython 7.1.1
OS Darwin 17.7.0 x86_64 i386 64bit
numpy 1.15.4
scipy 1.1.0
matplotlib 3.0.2
MotionClouds 20180606
Wed Nov 14 20:41:10 2018 CET

Comments

Comments powered by Disqus