Error描述
C:\WORK\Python\python.exe C:/Users/雪山飞狐/Desktop/研究生资料/数字图像处理/shiyan1.py
Traceback (most recent call last):File "C:/Users/雪山飞狐/Desktop/研究生资料/数字图像处理/shiyan1.py", line 23, in <module>img_4 = downsampling(img, 4)File "C:/Users/雪山飞狐/Desktop/研究生资料/数字图像处理/shiyan1.py", line 19, in downsamplingnew_img[a][b] = img[i][j]
ValueError: setting an array element with a sequence.
解决方案
翻译:ValueError:使用序列设置数组元素。
这里我遇到该情况的原因是
new_img = np.zeros((x, y), dtype=img.dtype)
初始化的时候没有给深度初始化,却在后面尝试插入一个RGB数组
改为
new_img = np.zeros((x, y,3), dtype=img.dtype)
就好了