Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PNG文件的签名无效_Python_Image Processing_Computer Vision - Fatal编程技术网

Python PNG文件的签名无效

Python PNG文件的签名无效,python,image-processing,computer-vision,Python,Image Processing,Computer Vision,我正在进行全景图像拼接,在imread函数中,我发现格式错误:PNG文件的签名无效。我在谷歌上搜索了一下,但没有找到任何内容。你能解释一下错误的原因吗 编辑:baseInputPath+path=Input/PanoramaImage30/image1.png baseInputPath='Input/' baseOutputPath='Output/' def imread(path='in.png'): '''reads a PNG RGB image at baseInputPa

我正在进行全景图像拼接,在imread函数中,我发现格式错误:PNG文件的签名无效。我在谷歌上搜索了一下,但没有找到任何内容。你能解释一下错误的原因吗

编辑:baseInputPath+path=Input/PanoramaImage30/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

开始时,我将jpeg文件转换为png文件,因此文件已损坏。现在,我将其重新转换并成功地工作。

可能您的一个png文件已损坏或根本不是png文件。你能在图像查看器中打开它吗?谢谢你的评论。一开始我将jpeg文件转换为png,所以文件已损坏。现在重新转换并成功。