IndexError:图像索引超出范围

时间:2017-10-21 22:17:25

标签: python python-imaging-library

def main():

    im = Image.open('terrain.png')
    ter = im.load()

    terr = []
    for row in range(500):
        trow = []
        for col in range(400):
            if ter[col,row][0:3] not in terrains:

                print((row,col))
                trow.append(5)
            else:
                trow.append(terrains[ter[col,row][0:3]])
        terr.append(trow)
    source = (200, 200)
    destination = (300, 300)
  

文件“/Users/pranushasoma/Downloads/hw1b.py”,第175行,主要

if ter[col,row][0:3] not in terrains:
     

IndexError:图像索引超出范围

我该怎么办这个错误?

0 个答案:

没有答案