1
我正在全景圖像拼接和imread函數中我得到格式錯誤:PNG文件有無效簽名。我使用了它,但我沒有找到任何東西。你能解釋我錯誤的原因?PNG文件有無效的簽名
編輯:baseInputPath +路徑=輸入/ 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文件。你可以在圖像查看器中打開它嗎? – DyZ
感謝您的評論。在開始我將jpeg文件轉換爲PNG文件損壞。現在重新轉換它,並與成功工作。 –