从数组生成图像时出现错误

时间:2018-09-15 02:10:37

标签: python-3.x

img_out.itemset[int(i),int(j)],int(b)
TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'    

谁能告诉我,为什么会发生此错误?

import numpy as np
import cv2
img = cv2.imread('/home/god/Downloads/images/flower.png')
img_out = img.copy()
cv2.imshow('image',img)
height = img.shape[0]
width = img.shape[1]

gauss = (1.0/57)*np.array(
     [[0,1,2,1,0],
      [1,3,5,3,1],
      [2,5,9,5,2],
      [1,3,5,3,1],
      [0,1,2,1,0]])

sum(sum(gauss))
for i in np.arange(2,height-2):
for j in np.arange(2,width-2):
    sum = 0
for k in np.arange(-2,3):
    for l in np.arange(-2,3):
         a = img[i+k,j+l]
         p = gauss[2+k,2+l]
         sum = sum+(p+a)
b = sum
img_out.itemset[i,t(j)],int(b)
cv2.imshow('image',img_out)
cv2.waitKey(0)
cv2.destroyAllWindows()

有人知道此代码有什么问题吗?如何将两个数组的值相加,然后将修改后的数组放入图像中。

0 个答案:

没有答案