Table of Contents

NAME

QccHYPklt - data structure QccHYPklt for spectral KLT transform

SYNOPSIS

#include "libQccPack.h"

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);

DESCRIPTION

QccPack provides data structure QccHYPklt for representing a KLT transform.

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.

DATA STRUCTURE

The QccHYPklt data structure is defined as:

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:

filename
The name of the file.
magic_num, major_version, minor_version
The magic number and version of the file.
num_bands
The number of spectral bands the KLT is designed for.
mean
The mean vector (length = num_bands).
matrix
The transform matrix (size = num_bands x num_bands).

FILE FORMAT

For reading and writing structures of type QccHYPklt, QccPack provides the KLT file format. This file format starts with an ASCII header followed by binary data. The ASCII header consists of magic-number/revision information followed by any amount of white space (space, `\t' (tab), `\n' (newline), `\r' (return)) and/or comments lines (lines starting with `#'). Following this white space, additional ASCII header information is given, separated by blanks and newlines. Binary data follows this ASCII header information.

The KLT file format consists of the following information:

KLTX.X
<white space>
num_bands
mean
.
.
.
matrix
.
.
.

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.

ROUTINES

QccHYPkltInitialize() should be called before any use of a QccHYPklt structure. QccHYPkltInitialize() initializes the fields of klt to the following values:

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.

THEORY

The Karhunen-Loève transform (KLT) is a data-dependent linear transform that is optimal in the sense that it packs the most signal energy into a given number of transform coefficients.

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.

RETURN VALUE

These routines return 0 on success, and 1 on failure.

SEE ALSO

QccHYPkltTrain(3) , QccHYPkltTransform(3) , QccHYPkltInverseTransform(3) , QccMatrixSVD(3) , QccIMGImageCube(3) , QccPackHYP(3) , QccPackIMG(3) , QccPack(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads