int QccHYPkltInitialize(QccHYPklt *klt);
int QccHYPkltAlloc(QccHYPklt *klt);
void QccHYPkltFree(QccHYPklt *klt);
int QccHYPkltPrint(const QccHYPklt *klt);
int QccHYPkltRead(QccHYPklt
*klt);
int QccHYPkltWrite(const QccHYPklt *klt);
The components of a QccHYPklt structure are a vector representing the dataset mean and a matrix representing the transform itself, as determined by a singular value decomposition of the dataset's covariance matrix.
typedef struct
{
QccString filename;
QccString magic_num;
int major_version;
int minor_version;
int num_bands;
QccVector mean;
QccMatrix matrix;
} QccHYPklt;
The fields of QccHYPklt are as follows:
The KLT file format consists of the following information:
where KLT is the magic number, X.X is the version number, <white space> is white space and/or comment lines, num_bands is the number of bands, mean are the elements of the mean vector, and matrix are the elements of the transform matrix. num_bands is stored in ASCII, while the mean and matrix values are stored as binary (4 bytes, MSB first, see QccFileWriteDouble(3) ). No white space may exist between the mean and matrix values.KLTX.X
<white space>
num_bands
mean
.
.
.
matrix
.
.
.
filename: NULL string
magic_num: QCCFILTERBANK_MAGICNUM
major_version, minor_version: initialized to output of QccGetQccPackVersion(3)
num_bands: 0
mean: NULL
matrix: NULL
QccHYPkltAlloc() allocates the mean and matrix fields of the KLT. num_bands must be set prior to calling QccHYPkltAlloc().
QccHYPkltFree() frees the mean and matrix fields of klt.
QccHYPkltPrint() prints the contents of klt to stdout.
QccHYPkltRead() reads a QccHYPklt structure from a file; the filename of the KLT-format file to be read must be stored as klt->filename.
QccHYPkltWrite() writes a QccHYPklt structure to a file; the filename of the KLT-format file to be written must be stored as klt->filename.
The KLT is often used for spectral decorrelation in a hyperspectral image. Let X be a collection of pixel vectors; i.e., X is a num_bands x num_pixels matrix, where num_bands is the number of spectral bands in the hyperspectral image. Let u be the mean vector of the pixel vectors (a num_bands x 1 vector). The covariance matrix R of X is then R = X*X^T/num_pixels - u*u^T, where the size of R is num_bands x num_bands. The singular value decomposition of R is R = U*S*V^T, where U is the transform matrix for the KLT (size num_bands x num_bands).
The forward KLT transform is applied to the dataset in question using the transpose of the matrix U. Specifically, for a num_bands x 1 pixel vector x, the forward KLT is y = U^T*(x - u). The inverse KLT transform uses the matrix U directly; i.e., x = U*y + u. Here, u is the mean vector.
In QccPack, QccHYPkltTrain(3) determines the mean vector u and the transform matrix U given the set of pixel vectors in a hyperspectral image; QccHYPkltTrain(3) uses QccMatrixSVD(3) to perform the SVD of the covariance matrix. For application of the forward and inverse transforms to the image cube, use QccHYPkltTransform(3) and QccHYPkltInverseTransform(3) , respectively.
The KLT is also called the Hotelling transform or principal component analysis (PCA). The name PCA is typically used when only a subset of transform coefficients (i.e., the principal components) is retained; that is, PCA typically refers to dimensionality reduction in addition to the spectral decorreltation inherent in the KLT.