2017-09-16 31 views
0

的陣列創建影片我已在下面的代碼片斷:從圖像

X=[] 
for val in range(64): 
    ap_pix=amp_phas[:,val] 
    im=plt.imshow(ap_pix.reshape(50,50),cmap=plt.get_cmap('plasma')) 
    X.append(im) 

amp_phas爲(2500×64)陣列,使得循環的每個步驟創建存儲一個50×50個圖像到數組X. 我在Jupyter筆記本中使用Python 3。

如何從數組X中創建電影或幻燈片放映?

+0

請詳細信息添加到您的問題。你使用哪種編程語言?你需要什麼確切的輸出?創建**電影**並不能清楚地描述你想要的輸出。 – Nima

回答

0

我能夠使用imageio和mimsave解決此問題。

這是我的最終代碼:

filenames=[]  # array that stores the filename of each image 
for val in range(64): 
    ap_pix=amp_phas[:,val] # array that contains the image data 
    im=plt.imshow(ap_pix.reshape(50,50),cmap=plt.get_cmap('plasma')) 
    plt.colorbar() 
    a='C:/yada/yada/'+ str(val)+'.png'  #filename of each array with the location where it is to be saved 
filenames.append(a) # adding the file name to filenames[] 
plt.savefig(a)  #saving the figure 
plt.clf()   #clearing the figure so that the colorbars don't pile up 

import imageio 
images = []  #array to store the images 
for filename in filenames: 
    images.append(imageio.imread(filename)) #reading the images into into images[] 
imageio.mimsave('C:/yada/yada/movie.gif', images) #movie making 

的GIF的幀速率可以通過以下方式進行調整:

imageio.mimsave('C:/yada/yada/movie.gif', images,duration=0.5)