以下内容将 png 读入数组:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img=mpimg.imread('example.png')
结果是数组img
,例如 1024 x 1024 元组数组(参见http://matplotlib.org/1.3.1/users/image_tutorial.html):
我如何强制执行,我的结果是 nx n 数组(元组)而不是 1024 x 1024 数组(n<1024)?我需要明确定义该数组的维度(例如设置 400x400)。
提前致谢