【发布时间】:2017-02-28 06:15:37
【问题描述】:
我正在处理全景图像拼接,在 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
【问题讨论】:
-
您的某个 PNG 文件可能已损坏或根本不是 PNG 文件。可以在图片查看器中打开吗?
-
感谢您的评论。一开始我将 jpeg 文件转换为 png,因此文件损坏。现在重新转换并成功。
标签: python image-processing computer-vision