【问题标题】:Image reconstruction using eigen vector使用特征向量进行图像重建
【发布时间】:2018-01-28 05:57:20
【问题描述】:
【问题讨论】:
标签:
image-processing
pca
eigenvalue
eigenvector
【解决方案1】:
当您拥有主成分 (PC) 后,您可以通过使用 PC 和您的数据计算点积来降低维度,如下所示。
def projectData(X, U, K):
# Compute the projection of the data using only the top K eigenvectors
# in U (first K columns).
# X: data
# U: Eigenvectors
# K: your choice of dimension
new_U = U[:,:K]
return X.dot(new_U)
现在,我们如何取回原始数据?通过使用 U 中的前 K 个特征向量投影回原始空间。
def recoverData(Z, U, K):
# Compute the approximation of the data by projecting back onto
# the original space using the top K eigenvectors in U.
# Z: projected data
new_U = U[:, :K]
return Z.dot(new_U.T) # We can use transpose instead of inverse because U is orthogonal.