特征图像函数生成一条窄条而不是平均图像

时间:2019-06-06 10:45:35

标签: python numpy eigenvalue eigenvector

我从书中获得了此功能:

def EigenImages( d ):
    N,V,H = d.shape
    dd = d.astype(float) - d.astype(float).mean(0)
    L = np.zeros( (N,N) )
    for i in range( N ):
        L[i,i] = (dd[i] * dd[i]).sum()
        for j in range( i ):
             L[i,j] = L[j,i] = (dd[i] * dd[j] ).sum()
    evls, evcs = np.linalg.eig( L )
    emgs = []
    for j in range( N ):
        a = np.zeros( (V,H) )
        for i in range( N ):
            a += evcs[i,j]*dd[i]
        emgs.append( a/np.sqrt(evls[j]) )
    return emgs, evls

但是它不能正常工作。与其生成特征图像,不如生成一条窄条: enter image description here

怎么了?

0 个答案:

没有答案