看板 Python 關於我們 聯絡資訊
程式碼如下: error message Traceback (most recent call last): File "hw1-4.py", line 20, in <module> bigdata[0:height,0:width]=data.copy() ValueError: could not broadcast input array from shape (320,320,3) into shape (320,320) 想問一下要如何解 謝謝 ****************************** from PIL import Image import numpy as np dtable=np.array([[62,57,48,36,37,49,58,63], [56,47,35,21,22,38,50,59], [46,34,20,10,11,23,39,51], [33,19, 9, 3, 0, 4,12,24], [32,18, 8, 2, 1, 5,13,25], [45,31,17, 7, 6,14,26,40], [55,44,30,16,15,27,41,52]]) im = Image.open( "lena.jpg" ); data = np.array(im) height,width,chanel = data.shape rx,offx=divmod(width,8) ry,offy=divmod(height,8) bigdata=np.zeros([(ry+1)*8,(rx+1)*8],dtype='uint8') bigdata[0:height,0:width]=data.copy() -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.0.31 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1570504046.A.40D.html
al96: bigdata[0:height,0:width,:]=data.copy() 10/09 20:01
al96: 這行也要改bigdata=np.zeros([(ry+1)*8,(rx+1)*8,China’s], 10/09 20:05
al96: dtype='uint8') 10/09 20:05
al96: China’s 選自錯誤,應該是chanel 10/09 20:06