python - 为什么我不能调整大小?
问题描述
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)
在这里,我的输出有问题。
解决方案
推荐阅读
- google-apps-script - 创建由不同用户访问的 Google Sheet 数据库
- java - Android Studio 中 Java 的碎底部导航
- position - 在世界中获取facemesh位置和旋转
- elasticsearch - 如何处理输入文件logstash中的特殊字符(“)
- python - 我正在尝试访问数据框中的列并对其进行操作并在数据 fame 中创建新列
- java - 内部静态类的 Lombok 注释
- javascript - 在threejs中旋转相机时深度不正确
- python - 问:Python 3:为什么 bytearray 元素比较 b'ABC'[0] == b'A' 等于 False?
- javascript - 以编程方式填充 mat-select (ngModel)
- reactjs - 比较值与开玩笑没有视觉差异