PCA of RGB Image

南笙酒味 提交于 2019-12-05 11:36:56

If there are three bands (which is the case for an RGB image), you need to reshape your image like

X = X.reshape(-1, 3)

In your case of a 512x512 image, the new X will have shape (262144, 3). The dimension of 3 will not throw off your result; that dimension represents the features in the image data space. Each row of X is a sample/observation and each column represents a variable/feature.

The total amount of variance in the image is equal to np.sum(S), which is the sum of eigenvalues. The amount of variance you retain will depend on which eigenvalues/eigenvectors you retain. So if you only keep the first eigenvalue/eigenvector, then the fraction of image variance you retain will be equal to

f = S[0] / np.sum(S)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!