[問題] Image dithering 問題

作者: materies (說)   2019-10-08 11:06:59
程式碼如下:
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()
作者: al96 (暖暖)   2019-10-09 20:01:00
bigdata[0:height,0:width,:]=data.copy()這行也要改bigdata=np.zeros([(ry+1)*8,(rx+1)*8,China’s],dtype='uint8')China’s 選自錯誤,應該是chanel

Links booklink

Contact Us: admin [ a t ] ucptt.com