Put the hyperspectral (HS) image into a DxN matrix X where D is the dimension of the data (no of HS bands) and N is the number of HS pixels; then calculate the covariance of X:
CovMat = cov(X'); %'
Now suppose you are interested in only 3 principal components so you need to
find the 3 directions that the variance of the data is largest:
[V E] = eigs(CovMat, 3);
The first 3 cols of V are the first 3 principal components
and forms the subspace that you are projecting the data to:
A = [V(:,1) V(:,2) V(:,3)];
Project your data to that subspace:
Y = X'*A; %'
This is the visualization of X projected to its 1st 3 principal components:
figure; plot3(Y(:, 1), Y(:, 2), Y(:, 3), '.')
If image is very large randomly choose a subset of the pixels to make X smaller.