首页 > 解决方案 > 为什么我不能调整大小?

问题描述

def create_data_matrix_from_video(clip, k=5, scale=50):
    return np.vstack([scipy.misc.imresize(rgb2gray(clip.get_frame(i/float(k))).astype(int), 
                      scale).flatten() for i in range(k * int(clip.duration))]).T
def rgb2gray(rgb):
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])

scale = 25   # Adjust scale to change resolution of image
dims = (int(240 * (scale/100)), int(320 * (scale/100)))

M = create_data_matrix_from_video(video, 100, scale)

print(dims, M.shape)

plt.imshow(np.reshape(M[:,140], dims), cmap='gray');

错误:

cannot reshape array of size 6336 into shape (60,80)

在这里,我的输出有问题。

标签: pythonimage-processing

解决方案


推荐阅读