Created
April 2, 2019 02:36
-
-
Save robbibt/18c782fcac6a04014ac30ab8fac36f17 to your computer and use it in GitHub Desktop.
Take two images and export frames fading between both images with a smooth transition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import imageio | |
| import numpy as np | |
| from_array = imageio.imread('Visualisation/pilbara/pilbara_before.png') | |
| to_array = imageio.imread('Visualisation/pilbara/pilbara_after.png') | |
| stacked_from_to = np.stack([to_array, from_array], axis=3) | |
| weights = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.6, 0.4, 0.2, 0] | |
| milliseconds = [50, 50, 50, 50, 3500, 50, 50, 50, 50, 3500] | |
| for i, weight in enumerate(weights): | |
| ave_from_to = np.average(stacked_from_to, axis=3, weights=np.array([weight, 1.0 - weight])) | |
| imageio.imwrite(f'Visualisation/pilbara/output_{i}_({milliseconds[i]}ms).png', ave_from_to.astype(np.uint8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment