def projection_matrix(point_set, subspace_rank = 2):
"""
Compute the projection matrix of a set of point depending on the subspace rank.
Args:
- point_set (np.array): list of coordinates of shape (n_point, init_dim).
- dimension_reduction (int) : the dimension reduction to apply
"""
point_set = np.array(point_set)
nb_coord = point_set.shape[0]
init_dim = point_set.shape[1]
assert init_dim > subspace_rank
assert subspace_rank > 0
centroid = point_set.mean(axis=0)
if sum(centroid) != 0:
# - Compute the centered matrix:
centered_point_set = point_set - centroid
else:
centered_point_set = point_set
# -- Compute the Singular Value Decomposition (SVD) of centered coordinates:
U,D,V = svd(centered_point_set, full_matrices=False)
V = V.T
# -- Compute the projection matrix:
H = np.dot(V[:,0:subspace_rank], V[:,0:subspace_rank].T)
return H
spatial_image_analysis.py 文件源码
python
阅读 45
收藏 0
点赞 0
评论 0
评论列表
文章目录