Beispiel #1
0
def save_frame(idx):

    w = z * (1.0 - interp[idx]) + np.tan(1 / z) * (interp[idx])

    cfunc_plot = dcoloring.colorize(w, grid=False)

    fig = plt.figure()
    ax = fig.add_subplot(111)

    ax.imshow(cfunc_plot,
              extent=(-WIDTH / 2, WIDTH / 2, -HEIGHT / 2, HEIGHT / 2))
    ax.set(xlabel='{:3.0f}%'.format(interp[idx] * 100), title=func_name)

    # Save frame
    print('Rendering frame {0:{2}}/{1:{2}}'.format(idx, FRAMES,
                                                   int(np.log10(FRAMES) + 1)))
    temp_path = '{}/frame.{}.png'.format(TEMP_DIR, idx)
    fig.savefig(temp_path, dpi=600, transparent=True)

    # Resize for aliasing
    img = cv2.imread(temp_path)
    img = cv2.resize(img, (int(img.shape[1] / 3), int(img.shape[0] / 3)),
                     interpolation=cv2.INTER_AREA)
    cv2.imwrite(temp_path, img)

    # Save image of complete function
    if idx == FRAMES - 1:
        img_path = '{}.png'.format(path)
        fig.savefig(img_path, dpi=1600, transparent=True)
        img = cv2.imread(img_path)
        img = cv2.resize(img, (int(img.shape[1] / 4), int(img.shape[0] / 4)),
                         interpolation=cv2.INTER_AREA)
        cv2.imwrite('{}.png'.format(path), img)

    plt.close(fig)
Beispiel #2
0
import cv2

WIDTH = 12
HEIGHT = 24
HEIGHT_OFFSET = 11
POINTS_PER_DIM = 2048

x, y = np.ogrid[-WIDTH / 2:WIDTH / 2:POINTS_PER_DIM / 2 * 1j, HEIGHT_OFFSET +
                (-HEIGHT / 2):HEIGHT_OFFSET + (HEIGHT / 2):POINTS_PER_DIM * 1j]

fig = plt.figure()
ax = fig.add_subplot(111)

z = x + 1j * y

z_img = dcoloring.colorize(np.vectorize(dcoloring.zeta)(z, E=1e-9), grid=False)

ax.set(title='f(z)')
ax.imshow(z_img,
          extent=(-WIDTH / 2, WIDTH / 2, HEIGHT_OFFSET + (-HEIGHT / 2),
                  HEIGHT_OFFSET + (HEIGHT / 2)))

path = 'f(z).png'
fig.savefig(path, dpi=1600, transparent=True)

# Resize for aliasing
img = cv2.imread(path)
img = cv2.resize(img, (int(img.shape[1] / 4), int(img.shape[0] / 4)),
                 interpolation=cv2.INTER_AREA)
cv2.imwrite(path, img)
Beispiel #3
0
bias2 = dcoloring.clover(2 * t)
weight3 = dcoloring.clover(3 * t)
bias3 = dcoloring.clover(3 * t, -np.pi / 2)

#This loop goes over each weight and bias and generates a plot for each
#These plots are aggregated to make a video showcasing some of the function space

file_names = []
fig = plt.figure()
ax = fig.add_subplot(111)

for idx in range(0, len(t)):
    w = np.exp(weight1[idx] * np.log(weight2[idx] * np.exp(z) + bias2[idx]) +
               bias1[idx])

    img = dcoloring.colorize(w, grid=False)

    ax.clear()
    ax.imshow(img, extent=(-WIDTH / 2, WIDTH / 2, -HEIGHT / 2, HEIGHT / 2))
    ax.set_xlim(-WIDTH / 2, WIDTH / 2)
    ax.set_ylim(-HEIGHT / 2, HEIGHT / 2)
    ax.set(xlabel='{}'.format(idx))

    print('Rendering frame {0:{2}}/{1:{2}}'.format(idx, FRAMES,
                                                   int(np.log10(FRAMES) + 1)))
    fig.savefig('{}/frame.{}.png'.format(TEMP_DIR, idx))
    file_names.append('{}/frame.{}.png'.format(TEMP_DIR, idx))

render.create_webm('graph', file_names)
rmtree(TEMP_DIR)
Beispiel #4
0
    fig = plt.figure()
    ax = fig.add_subplot(111)

    # Set interpolation and animate transition between two complex functions

    file_names = []
    path = OUT_DIR + '/' + func_name
    if not os.path.exists(TEMP_DIR):
        os.makedirs(TEMP_DIR)

    interp = cerp
    for idx in range(0, len(interp)):
        w = z * (1.0 - interp[idx]) + cfunction * (interp[idx])

        cfunc_plot = dcoloring.colorize(w, grid=False, log_base=log_base)

        ax.clear()
        ax.imshow(cfunc_plot, extent=(-WIDTH/2, WIDTH/2, HEIGHT_OFFSET + (-HEIGHT / 2), HEIGHT_OFFSET + (HEIGHT / 2)))
        ax.set(xlabel='{:3.0f}%'.format(round(interp[idx] * 100)), title=func_name)

        # Save frame
        print('Rendering frame {0:{2}}/{1:{2}}'.format(idx + 1, FRAMES, int(np.log10(FRAMES) + 1)))
        temp_path = '{}/frame.{}.png'.format(TEMP_DIR, idx)
        fig.savefig(temp_path, dpi=1000, transparent=True)
        file_names.append(temp_path)

        # Resize for aliasing
        img = cv2.imread(temp_path)
        img = cv2.resize(img, (int(img.shape[1]/8), int(img.shape[0]/8)), interpolation=cv2.INTER_AREA)
        cv2.imwrite(temp_path, img)
Beispiel #5
0
    fig = plt.figure()
    ax = fig.add_subplot(111)


    # Set interpolation and animate transition between two complex functions

    file_names = []
    path = OUT_DIR + '/' + func_name
    if not os.path.exists(TEMP_DIR):
        os.makedirs(TEMP_DIR)

    interp = cerp
    for idx in range(0, len(interp)):
        w = z * (1.0 - interp[idx]) + cfunction * (interp[idx])

        cfunc_plot = dcoloring.colorize(w, grid=False)

        ax.clear()
        ax.imshow(cfunc_plot, extent=(-WIDTH/2, WIDTH/2, -HEIGHT/2, HEIGHT/2))
        ax.set(xlabel='{:3.0f}%'.format(1.0 * 100), title=func_name)

        # Save frame
        print('Rendering frame {0:{2}}/{1:{2}}'.format(idx + 1, FRAMES, int(np.log10(FRAMES) + 1)))
        temp_path = '{}/frame.{}.png'.format(TEMP_DIR, idx)
        fig.savefig(temp_path, dpi=1600, transparent=True)
        file_names.append(temp_path)

        # Resize for aliasing
        img = cv2.imread(temp_path)
        img = cv2.resize(img, (int(img.shape[1]/4), int(img.shape[0]/4)), interpolation=cv2.INTER_AREA)
        cv2.imwrite(temp_path, img)
Beispiel #6
0
import numpy as np
import dcoloring
import cv2

WIDTH = 16.0
HEIGHT = 16.0
POINTS_PER_DIM = 2048

x, y = np.ogrid[
    -WIDTH/2:WIDTH/2:POINTS_PER_DIM*1j,
    -HEIGHT/2:HEIGHT/2:POINTS_PER_DIM*1j
]

fig = plt.figure()
ax = fig.add_subplot(111)

z = x + 1j*y

z_img = dcoloring.colorize(z, grid=False)

ax.set(title='z')
ax.imshow(z_img, extent=(-WIDTH/2,WIDTH/2,-HEIGHT/2,HEIGHT/2))

path  = 'z.png'
fig.savefig(path, dpi=1600, transparent=True)

# Resize for aliasing
img = cv2.imread(path)
img = cv2.resize(img, (int(img.shape[1]/4), int(img.shape[0]/4)), interpolation=cv2.INTER_AREA)
cv2.imwrite(path, img)