[問題] Image dithering 問題

看板Python作者 (說)時間5年前 (2019/10/08 11:07), 編輯推噓2(202)
留言4則, 1人參與, 5年前最新討論串1/1
程式碼如下: 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

10/09 20:01, 5年前 , 1F
bigdata[0:height,0:width,:]=data.copy()
10/09 20:01, 1F

10/09 20:05, 5年前 , 2F
這行也要改bigdata=np.zeros([(ry+1)*8,(rx+1)*8,China’s],
10/09 20:05, 2F

10/09 20:05, 5年前 , 3F
dtype='uint8')
10/09 20:05, 3F

10/09 20:06, 5年前 , 4F
China’s 選自錯誤,應該是chanel
10/09 20:06, 4F
文章代碼(AID): #1Tc_rkGD (Python)
文章代碼(AID): #1Tc_rkGD (Python)