Smooth transition between MCs

In [1]:
"""
A smooth transition while changing parameters

(c) Laurent Perrinet - INT/CNRS

"""

import MotionClouds as mc
import numpy as np
import os

name = 'smooth'

#initialize
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)

name_ = mc.figpath + name

seed = 123456
B_sf_ = [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 i_sf, B_sf in enumerate(B_sf_):
    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_)
In [2]:
name_ += '_smooth'
smooth = (ft - ft.min())/(ft.max() - ft.min()) # smoothly progress from 0. to 1.
N = len(B_sf_)
im =  np.empty(shape=(mc.N_X, mc.N_Y, 0))
for i_sf, B_sf in enumerate(B_sf_):
    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_sf_[(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_)

Comments

Comments powered by Disqus