PNG文件的signatu无效

2024-06-16 14:44:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在研究全景图像拼接,在imread函数中我得到了格式错误:PNG文件有无效的签名。我在谷歌上搜索,但没有找到什么都可以你给我解释一下出错的原因?在

编辑:baseInputPath+path=Input/panoramage30/image1.png

baseInputPath='Input/'
baseOutputPath='Output/'

def imread(path='in.png'):
    '''reads a PNG RGB image at baseInputPath+path and return a numpy array organized along Y, X, channel.
    The values are encoded as float and are linearized (i.e. gamma is decoded)'''
    global baseInputPath
    print baseInputPath+path
    reader=png.Reader(baseInputPath+path)
    im=reader.asFloat()
    a=numpy.vstack(im[2])
    if im[3]['greyscale']:
        raise NameError( 'Expected an RGB image, given a greyscale one')        
    x, y=im[0], im[1]
    a.resize(y, x, 3)
    a**=2.2
    return a

Tags: andpathimagenumpyinputreturnpngrgb