本文介绍了我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的程序中收到此错误
回溯(最近一次调用最后一次):
i am getting this error in my program
Traceback (most recent call last):
File "D:\Python\programs\IMG PRO\im.py", line 30, in <module>
threshhold(iar)
File "D:\Python\programs\IMG PRO\im.py", line 17, in threshhold
echpix[0]=255
ValueError: assignment destination is read-only
我尝试过:
What I have tried:
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import time
def threshhold(imagearray):
newa=imagearray
bal=list()
for echrow in imagearray:
for echpix in echrow:
avg=sum(echpix[:3])/3
bal.append(avg)
s=sum(bal[0:])
balance=s/len(bal)
for echrow in newa:
for echpix in echrow:
if (sum(echpix[:3])/3)>balance:
echpix[0]=255
echpix[1]=255
echpix[2]=255
echpix[3]=255
else:
echpix[0]=0
echpix[1]=0
echpix[2]=0
echpix[3]=255
print newa
im=Image.open('../images/numbers/y0.3.png')
iar=np.asarray(im)
threshhold(iar)
fig=plt.figure()
ax1=plt.subplot2grid((8,6),(0,0),rowspan=4,colspan=3)
ax1.imshow(iar)
plt.show()
推荐答案
这篇关于我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!