读取pnm文件的Python程序

时间:2014-02-25 01:53:12

标签: python image image-processing

我需要创建一个程序,使用找到here的mcsp.wartburg.edu graphics.py库来读取pnm文件。到目前为止,这就是我所拥有的:

from graphics import *

#Function chunks the list into groups of n, for example,
#List = ['2', '3', '4', '5', '6', '7', '8', '9', '10']
#with chucker lists becomes ['2', '3', '4'] and ['5','6','7'] and so on

def chunker(seq, size):
    return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))

def main():

fText =open("rainbowGS1.pnm", "r")
data = fText.readlines()
fText.close()

for ch in chunker(data[3:], 3):
    print ch

我不确定如何使用找到here的setPixel(x,y,color)函数和color = color_rgb(255,0,0)函数来获取这些组并设置其RGB值。我不能使用color_rgb(ch),因为这个函数接受3个参数。通过使用color_rgb(ch)传递一个参数。非常感谢帮助,谢谢!

0 个答案:

没有答案