1
回答
python 中给坐标赋值,为什么会提示ValueError: setting an array element with a sequence.

def pixel_Simi(cells):

    cellValue = get_cellvalue(cells)
    Ih,Is,Iv = cellValue
    H,S,V = cells
    cellx,celly= 8,8
    pixel_Simi = np.zeros((cellx,celly),dtype=float)
    for i in range(celly):
        for j in range(cellx):
            h,s,v = H[j:j+1,i:i+1],S[j:j+1,i:i+1],V[j:j+1,i:i+1]
            Simi = ((Ih - h)**2 + (Is - s)**2 + (Iv - v)**2) / ((Ih+h) + (Is+s) + (Iv+v))
            pixel_Simi[j,i] += Simi
    return pixel_Simi

 

我将得到的Simi值赋值给pixel_Simi[j,i]时提示:

ValueError: setting an array element with a sequence.

cell 是一个(8,8)的像素单元,

可是当我单独拿出来一个矩阵和数字进行将加时,是可行的,比如:

a = np.zeros( (8,8) , dtype=float)

a[1,3]  += [[3]]

a =array([[0. ,0. ,0. ,0. ,0. ,0. ,0. ,0.]

                  [0. ,0. ,0. ,3. ,0. ,0. ,0. ,0.]

                  [0. ,0. ,0. ,0. ,0. ,0. ,0. ,0]

                   ......)

哪位大神帮忙看看啊! 谢谢了

举报
YvetteLee
发帖于9个月前 1回/971阅
顶部