Python中的Imread()函数可以获得红色,绿色和蓝色。

时间:2013-07-18 13:15:11

标签: python bitmap bmp

我正在尝试使用imread()为1400x1400 bmp图片获取这些颜色。当我打印imread结果时,我得到一个1400x1400数字的整数数组。不应该有与R.G.B.A.X对应的5个数字 如下所示: http://en.wikipedia.org/wiki/BMP_file_format

import numpy as np
from scipy.misc import imread
from scipy import *
tally=0
#Read in the image
img = imread('M10.bmp',flatten=False)
print len(img[0])  #elements of first array element
print len(img)     #elements of array
print img,         #see what the array looks like
for line in img:
    for ch in line:
        print ch

print tally       #amount of numbers
print len(img[0])*len(img)   #amount of spaces in arrays (to check)

0 个答案:

没有答案