我想將圖像轉換爲一個numpy數組,當我這樣做時,它給了我在我的標題中提到的錯誤。 回溯錯誤來自行:ValueError:沒有足夠的值來解壓縮(預計2,got1)
nx,ny = np.shape(matrix)
我的代碼的其餘部分如下。我能否提出一些解決此問題的建議?
#change the quoted part to change directory and
#file type
filelist = glob.glob('Desktop/*.png')
#set Matrix as the numpy array.
#change the second half were np
#is used to make the program
#use a different set of data
matrix = np.array([np.array(Image.open(fname)) for fname in filelist])
#numpy array
nx,ny = np.shape(matrix)
CXY = np.zeros([ny, nx])
for i in range(ny):
for j in range(nx):
CXY[i,j] = np.max(matrix[j,i,:])
#Binary data
np.save('/home/l/Desktop/maximums.npy', CXY)
#Human readable data
np.savetxt('/home/l/Desktop/maximums.txt', CXY)
一個建議是包含你的FULL回溯,所以我們知道你在哪裏得到錯誤。 –
'nx,ny = np.shape(矩陣)'如果矩陣只有一個維度,這將是您的錯誤來源。 –
你可以包含錯誤追溯? –