2010-08-16 110 views

回答

23

scipy.misc.imread()会返回一个numpy的阵列,这是非常方便的很多事情。

+0

太棒了。像魅力一样工作。 – hatmatrix 2010-08-16 21:27:54

+2

即使没有安装PIL,matplotlib.imread也会读取.png(仅)。 – denis 2010-08-18 10:37:02

+0

denis,我想你的意思是'matplotlib.image.imread'。 – Garrett 2014-02-28 07:05:53

2

可以使用PyGame image和使用PixelArray访问PixelData取出

+0

感谢 - 我将有调查一下。现在,我碰巧有scipy和PIL已经安装... – hatmatrix 2010-08-16 21:28:23

6

到现在为止没有人告诉matplotlib.image

import matplotlib.image as img 
image = img.imread(file_name) 

现在的形象将是一个3D numpy的阵列

print image.shape 

会是这样的:(317, 504, 3)