How to use the imageio.mimsave function in imageio

To help you get started, we’ve selected a few imageio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imageio / imageio / tests / test_bsdf.py View on Github external
def test_random_access():

    im1 = imageio.imread("imageio:chelsea.png")
    ims1 = [im1, im1 * 0.8, im1 * 0.5]

    fname = os.path.join(test_dir, "chelseam.bsdf")
    imageio.mimsave(fname, ims1)

    r = imageio.get_reader(fname)

    for i in (1, 0, 2, 0, 1, 2):
        assert np.all(ims1[i] == r.get_data(i))
    # Note that if we would not get the data of one image in the series,
github SuzukiHonoka / Starx_Pixiv_Collector / start.py View on Github external
for root, dirs, files in os.walk(src_saved_dir):
        for file in files:
            if file.endswith('jpg') or file.endswith('png'):
                sort_by_num.append(src_saved_dir + global_symbol + file)
    sort_by_num.sort()
    print_with_tag(tag, 'Reading each frame..')
    for each_frame in sort_by_num:
        frames.append(imageio.imread(each_frame))
    gif_save_dir = save_path + str(prefix) + global_symbol + year_month + str(
        day) + global_symbol + 'D-' + str(illust_id) + global_symbol
    gif_name_format = re.sub('[\/:*?"<>|]', '_', str(title)) + '-' + str(illust_id) + '.gif'
    if not os.path.exists(gif_save_dir):
        os.makedirs(gif_save_dir)
    print_with_tag(tag, 'Synthesizing dynamic images..')
    try:
        imageio.mimsave(gif_save_dir + gif_name_format, frames, duration=src_img_delay)
    except Exception as e:
        print_with_tag(tag, [gif_save_dir + gif_name_format])
        print_with_tag(tag, e)
        exit()
github aaronpenne / data_visualization / same_sex_marriage / ssm_bar.py View on Github external
#for i in range(30):
#    charts.append(imageio.imread('{0}999.png'.format(output_dir)))

# Append all the charts (except the title slide)
for i,f in enumerate(png_files):
    charts.append(imageio.imread('{0}{1}'.format(output_dir, f)))
    if i % 8 == 0:
        for k in range(10):
            charts.append(imageio.imread('{0}{1}'.format(output_dir, f)))
            
# Append the last chart a few extra times
for i in range(10):
    charts.append(imageio.imread('{0}{1}'.format(output_dir, f)))

# Save gif
imageio.mimsave('{0}ssm_bar.gif'.format(output_dir), charts, format='GIF', duration=0.07)
github Parallel-in-Time / pySDC / pySDC / projects / AllenCahn_Bayreuth / visualize_temp.py View on Github external
ax[1].set_title(f"Temperature - Time: {obj['time']:6.4f}")

        fig.tight_layout()

        # draw the canvas, cache the renderer
        fig.canvas.draw()
        image = np.frombuffer(fig.canvas.tostring_rgb(), dtype='uint8')
        img_list.append(image.reshape(fig.canvas.get_width_height()[::-1] + (3,)))
        plt.close()

        # c += 1
        # if c == 3:
        #     break

    fname = f'{output}/{name}.mp4'
    imageio.mimsave(fname, img_list, fps=8)
github AliaksandrSiarohin / monkey-net / prediction.py View on Github external
kp_video[k][:, :init_frames] = kp_init[k][:, :init_frames]
            if 'var' in kp_video and prediction_params['predict_variance']:
                kp_video['var'] = kp_init['var'][:, (init_frames - 1):init_frames].repeat(1, kp_video['var'].shape[1],
                                                                                          1, 1, 1)
            out = generate(generator, appearance_image=x['video'][:, :, :1], kp_appearance=kp_source,
                           kp_video=kp_video)

            x['source'] = x['video'][:, :, :1]

            out_video_batch = out['video_prediction'].data.cpu().numpy()
            out_video_batch = np.concatenate(np.transpose(out_video_batch, [0, 2, 3, 4, 1])[0], axis=1)
            imageio.imsave(os.path.join(png_dir, x['name'][0] + '.png'), (255 * out_video_batch).astype(np.uint8))

            image = Visualizer(**config['visualizer_params']).visualize_reconstruction(x, out)
            image_name = x['name'][0] + prediction_params['format']
            imageio.mimsave(os.path.join(log_dir, image_name), image)

            del x, kp_video, kp_source, out
github mathewbarlow / potential-vorticity / gfs_pv_time_animation_1.0.py View on Github external
plt.colorbar(surf,shrink=0.5)
    
                    
    dirout = '/Users/mathew_barlow/downloads/'
    filename=dirout +'tp_3D'+ time_out +'.png'
    plt.savefig(filename, bbox_inches='tight')
    
    images.append(imageio.imread(filename))
    filenames.append(filename)
        
    plt.clf()

        
    it=it+1
    
imageio.mimsave(dirout+'tp_time_anim.gif', images)
#for file in filenames:
#    os.remove(file)

plt.close('all')

real_current_time = datetime.now().strftime("%H:%M:%S")
print(real_current_time)
github apozas / ml-projects / EnergyBasedModels-pytorch / rbm_example.py View on Github external
plt.figure(figsize=(20, 10))
zero = torch.zeros(25, 784).to(device)
images = [zero.cpu().numpy().reshape((5 * 28, 5 * 28))]
sampler.internal_sampling = True
for i in range(k_reconstruct):
    zero = sampler.get_h_from_v(zero, rbm.W, rbm.hbias)
    zero = sampler.get_v_from_h(zero, rbm.W, rbm.vbias)
    if i % 3 == 0:
        datas = zero.data.cpu().numpy().reshape((25, 28, 28))
        image = np.zeros((5 * 28, 5 * 28))
        for k in range(5):
            for l in range(5):
                image[28*k:28*(k+1), 28*l:28*(l+1)] = datas[k + 5*l, :, :]
        images.append(image)
sampler.internal_sampling = False
imageio.mimsave('RBM_sample.gif', images, duration=0.1)
github KarenUllrich / Tutorial_BayesianCompressionForDL / utils.py View on Github external
def generate_gif(save='tmp', epochs=10):
    images = []
    filenames = ["./." + save + "%d.png" % (epoch + 1) for epoch in np.arange(epochs)]
    for filename in filenames:
        images.append(imageio.imread(filename))
        os.remove(filename)
    imageio.mimsave('./figures/' + save + '.gif', images, duration=.5)
github maharshi95 / Pose2vec / pose / visualize.py View on Github external
def save_gif(imgs, gif_name):
    imageio.mimsave('{}/{}'.format(gif_path(), gif_name), imgs)
github PdxCodeGuild / 20180116-FullStack-Day / Code / Brianna / Python / Lab_16_FancyLenna / Image Manipulation 2 Saturation.py View on Github external
g = int(g * 255)
            b = int(b * 255)

            pixels[i, j] = r, g, b

            img.save("lenna" + mix + ".png")
            mix = mix + 1

png_dir = ""
images = []
for subdir, dirs, files in os.walk(png_dir):
    for file in files:
        file_path = os.path.join(subdir, file)
        if file_path.endswith(".png"):
            images.append(imageio.imread(file_path))
imageio.mimsave('.movie.gif', images)