User's Guide

KARLOV

Performs a Karhunen-Loeve transformation on a multiband image

Function:

Computes the principal components of a multi-band image by performing a Karhunen-Loeve transformation on the image. It utilizes the image mean and covariance statistics obtained by the program COVAR or the class mean and covariance obtained by the program STATS. The user may also input the desired transformation manually. The transformation is given by z = T(f-m), where T is a matrix whose rows are the eigen vectors of the covariance matrix, f is the input image multi-pixel vector, m is the mean vector, and z is the output image multi-pixel vector.

For the image mode, image covariance and mean vectors are used; for single class mode, the statistics of the specified class are used; and for total class mode, the average of all the class statistics weighted by their class probabilities are used. If mean subtraction is not desired, then z = Tf is computed. The output image is normally output as REAL*4 data. BYTE data may also be selected for output.

Parameters:

IN
Input image. The image to be transformed or to which the statistics file INSTAT corresponds. IN must be a multi-band image with data type of BYTE, INTEGER*2, INTEGER*4, or REAL*4. No output image is produced if OUTBANDS=0.

TRANSRC(FILE)
Source of the transformation matrix

  = FILE:  Statistics file.  INSTAT must 
           contain the name of the input 
           statistics file that has the needed 
           covariance and mean data.

  = TERM:  Terminal.  The user will be prompted for 
           the transformation matrix (Eigen vectors), 
           and the corresponding mean vector.

INSTAT(-- )
Input statistics file. Statistics file containing the mean and covariance statistics used to compute the transformation. This is required if TRANSRC=FILE.

STATMODE(IMAGE)
Statistics mode.

  = IMAGE:   Image statistics are used.
  = SCLASS:  Single class.  Statistics of the class 
             specified by CLASSNAM is used.
  = TCLASS:  Total class.  Combined statistics of all 
             classes are used.

CLASSNAM(--)
Class name. Specifies the name of the class whose statistics are to be used in the single-class mode. This is required if TRANSRC=FILE and STATMODE=SCLASS.

PRINT(TERM)
Output destination. Destination for the listing of eigenvalues and eigenvectors when they are computed.

  = --:         No Report
  = TERM:       Terminal.  Output is sent to the
                user's  terminal.
  = LP:         Line printer.  Output is sent to
                the printer defined by $PRINTER.
  = Filename:   User supplied filename.  Output
                is sent to the user supplied file
                with the extension ".prt".

OUT(--)
Output image. Specifies the output principal component image. OUT is required only if OUTBANDS > 0. It will have as many bands as the number of principal components specified by OUTBANDS.

OUTBANDS(0)
Output number of bands. Number of principal components in output image. Must be less than or equal to the number of bands in the input image. If defaulted, only the transformation matrix is computed; no output image is produced.

ODTYPE("R*4")
Output data type. The data type of the output image. Valid data types are:

   = BYTE:  BYTE data
   = R*4:   REAL*4 data

COMPS(-- )
Components to use to create output image. Any of the principal components may be chosen for the output image, up to and including the last principal component.The default is to use the first OUTBANDS components.

SUBMEAN(YES)
Subtract mean. Specifies whether or not the mean is subtracted from the image pixel values in the transformation as shown below.

  = YES:  Mean subtracted.  The transformation
          is z = T(f-m).  
  = NO:   Mean not subtracted.  The transformation 
          is z = Tf.  

Examples:

  1. LAS> karlov transrc=term in=balt.img out=balt.kar.img outbands=2 comps=(3,6) odtype="r*4"

    A K-L transformation is performed on the image BALT.IMG. The user is prompted to enter the transformation matrix from the terminal. The third and sixth principal components are output as REAL*4 data. The mean is subtracted during the transformation.

  2. LAS> karlov instat=balt.stat statmode=2 classnam=water in=monitor.img out=monbands.img outbands=1

    The transformation is performed on the image MONITOR.IMG and a single-band image is output to the user-specified file MONBANDS.IMG. The statistics for the single class WATER from the statistics file BALT.STAT are used.

Description/Algorithm:

The K-L transform generates a set of uncorrelated component images from the original multi-band image. It results in a lower-dimensional representation of the multi-band image that retains most of the variance from the original data.

The principal component vectors are computed at each image pixel point from the N original components of the multi-band image by the transformation z=Tf or Z=T(f-m), as desired. In this computation, f is a vector of intensity values associated with each pixel; m is the mean vector of the image; T is an N x N orthogonal transformation matrix, the rows of which are the normalized eigenvectors of the image covariance matrix C, arranged with the eigenvalues in descending order; and z is the vector of principal components, which is calculated independently at each pixel point. Only those selected components less than or equal to N are output.

If desired, the output image can be scaled to be BYTE values. For this case a two pass method is used. The transform is completed once to calculate the actual minimum and maximum (Emin and Emax) pixel values of the output image. The output image is then linearly scaled such that the range (Emin, Emax) is mapped to (0,255).

KARLOV has three modes of operation (specified by STATMODE):

   l.  Image Mode:  In the image mode, KARLOV uses the mean 
       vector and covariance matrix of the entire image as 
       produced by the program COVAR.  The eigenvalues and 
       eigenvectors of the covariance matrix C are computed to 
       generate the transformation matrix T.

   2.  Single Class Mode:  In the single-class mode (specified
       by CLASSNAM), the transformation matrix Tk is
       formed from the eigenvectors of the covariance matrix Ck
       of the specified class k.  The covariance matrix Ck and
       the class mean vector mk are obtained from a statistics
       file as produced by the program STATS.

   3.  Total Class Mode:  In the total class mode, KARLOV obtains
       the class mean vectors mk and the class covariance 
       matrices Ck for all classes k=l,...,K, and computes the 
       total mean vector

                        K
                   m = SUM pkmk
                       k=l

      and the total covariance matrix

                        K
                   C = SUM pkCk
                       k=l

      where K is the number of classes and pk is the class a priori
      probabilities.  The statistics are obtained from a statistics 
      file as produced by the program STATS.

Nonfatal Error Message:

  1. [karlov-apriori] No apriori probs in stats file; equal values assumed

    Equal apriori probability values are assumed for all classes.

Fatal Error Messages:

  1. [karlov-nbands] No. of input bands should be greater than 1

    Re-enter IN as a multi-band image.

  2. [karlov-obands] No. of output bands should be <= no. of input bands

    Re-enter the value of OUTBANDS.

  3. [karlov-zerocomp] Zero output components specified for user defined transformation

    TRANSRC was specified as TERM and no output components were specified for performing the transformation. Specify non-zero output components or TRANSRC should be set to FILE.

  4. [karlov-class] No class name specified

    STATMODE was specified as single class, but no class name was specified.

  5. [karlov-sfin] No statistics file specified

    Statistics file is required when TRANSRC=FILE.

  6. [karlov-nclass] No classes found in statistics file

    Recreate the statistics file by using STATS.

  7. [karlov-noclass] Class not found in the statistics file

    Check spelling of the class name. Run EDITSTAT to verify that the class name exists.

  8. [karlov-nomean] Mean vector not found in statistics file

    Recreate the statistics file by using STATS or COVAR.

  9. [karlov-statdim] Statistics file dimensions do not match with the image

    The number of bands in the input image is not the same as that used in creating the statistics file. Respecify the input image or recreate or edit the statistics file.

  10. [karlov-nocov] Covariance matrix not found in statistics file

    Recreate the statistics file by using STATS or COVAR.

  11. [karlov-zerocov] Covariance matrix contains all zeros

    Recreate the statistics file by using STATS or COVAR.

  12. [karlov-zerodiv] Division by zero attempted

    Check the input image and/or the transformation matrix.

  13. [karlov-alloc] Error allocating dynamic memory

    An error occurred allocating memory. Rerun, and if the error persits, contact the system manager.

  14. [karlov-fatal] Fatal error encountered

    A fatal error was encountered during processing. The error message preceding this message is the specific error encountered.

User Notes:

  1. KARLOV displays the eigenvalues, eigenvectors, the percentage of the total data variation for each eigenvalue, and the cumulative percentage variation of the eigenvalues on output.

  2. Processing time will be longer for BYTE output because a two pass method is used.