8481
Some details on ENVI's Principal Components algorithm
Principal Components Analysis (PCA), often referred to as a PC rotation, is a linear transformation of a multivariate dataset into a new coordinate system. For remote sensing applications, the multiple variables are typically the different wavelengths of a multispectral or hyperspectral image. Due to its ability to reduce the dimensionality of a dataset while retaining most of the variance, the PCA technique finds applications in many different scientific and engineering disciplines. As a result, several common ways of computing a PCA rotation have been developed. This article discusses ENVI's implementation of the PCA transformation.
The basic mathematics of a PCA
The matrix algebra behind the PCA is actually remarkably simple. The original image data are projected onto (i.e., matrix multiplied by) a transformation matrix to produce the PCA data. Of course, it is the contents of the transformation matrix, which is based on the covariance structure of the image, that gives the PCA its utility. ENVI's basic PCA algorithm is identical to that derived by John Richards in his book Remote Sensing Digital Image Analysis, An Introduction (2nd Edition, Springer-Verlag, 1993), where the transform is defined as:
y = G # x ( eq. 1)
where:
y = the transformed, or rotated data (i.e., the principal components data),
G = the transformation matrix,
x = the original data,
and # denotes matrix multiplication.
To derive the transformation matrix, first the image's covariance matrix is computed. The covariance matrix is a square, symmetric matrix of size [bands x bands] where the diagonal elements are band variances and the off-diagonals are band covariances. Next, the eigenvalues and eigenvectors of the covariance matrix are computed. The PCA's transformation matrix G is defined as the transpose of the eigenvector matrix.
Shifting the origin by mean-correcting the image data
Many of the variations in how the PCA is applied are actually related to how (or if) the original data are adjusted prior to being projected onto the transformation matrix. For example, before rotating the data some algorithms standardize the data (i.e., each image band) such that they have zero mean and unit variance. ENVI never standardizes the input data, however it does mean-correct the data before transforming them. In other words, before the original data are projected onto the transformation matrix, the band mean is subtracted. Thus, ENVI's PC algorithm is a slight variation of the one derived by Richards:
y = G # (x - mean) (eq. 2)
This mean-correction produces an origin shift in the resulting PCA's image such that its mean spectrum is zero in every band. Adjusting the position of the origin in this manner does not change the properties of the resulting PC image because the PCA is a rotation (a multiplication) while the mean shift is a translation (an addition). For example, a PCA image produced without the mean correction would differ from ENVI's PCA image by only a constant value in each band. The shift constants are equal to the original band means projected onto the transformation matrix (e.g., the shift constants can be calculated by substituting a vector of band means into the variable x in equation 1).
Using the correlation matrix instead of the covariance matrix
An alternative method of computing a PC rotation is to derive the transformation matrix on the eigenvectors of the correlation matrix instead of the covariance matrix. The correlation matrix is equivalent to a covariance matrix for an image where each band has been standardized to zero mean and unit variance. This method tends to equalize the influence of each band, inflating the influence of bands with relatively small variance and reducing the influence of bands with high variance. While it is less common to use this approach for normal remote sensing datasets, there are special situations when this method is preferable. ENVI allows the user to choose this option when setting up the PCA routine. This method should not be confused with standardizing the image data before projecting it onto the transformation matrix, which does not happen in ENVI even when the correlation matrix is selected for the PCA.
Reproducing ENVI's PCA step-by-step
To summarize the discussion above, in ENVI's PCA:
- The input image's covariance or correlation matrix is computed.
- The eigenvectors of the covariance or correlation matrix are computed.
- The mean is subtracted from the input image data.
- The mean-corrected image data are projected onto the transpose of the eigenvector matrix. In IDL, this step would look as follows:
pca_result = transpose(eigenvectors) ## (image_data)
where eigenvectors is a 2D array containing the eigenvectors in its columns and image_data is a 2D array containing the image spectra in its columns.
As you might expect, the inverse PCA is computed by projecting the PC rotated image data onto the inverse of the PCA transformation matrix:
inverse_pca = transpose(invert(eigenvectors)) ## (pca_data)