User's Guide

Performs Bayesian classification on a multi-band image

Function:

Applies a Bayesian maximum likelihood classifier to an image containing up to 256 bands to produce a classified image containing up to 256 classes. Statistics required for this process are retrieved from the statistics file associated with the input image.

Parameters:

IN
Input image. This is associated with the statistics file INSTAT. The data type of IN may be BYTE, INTEGER*2, INTEGER*4, or REAL*4.

INSTAT
Input statistics file. This may contain training site statistics related to the image to be classified. These statistics are usually generated by running the program STATS.

OUT
Output classified image. It will always contain BYTE data. The pixel values will represent the class assignments based on the class numbers defined in the input statistics file. That is, the first class listed in INSTAT will be class 1, the second class in INSTAT will be class 2, and so forth. If a subset of the classes is specified using NCLASS, the class numbers in OUT will still refer to the class ordering in INSTAT. Therefore, if classes 1 and 3 are selected, the output image will contain the values 1 and 3 and not 1 and 2.

OMAXCHI
Output image. If MAXCHI = MAX, OMAXCHI contains the maximum likelihood image. Each class assignment is associated with a likelihood value, which is scaled from 0 to 255. Thus low values indicate a low likelihood that the assignment was correct and high values indicate a high likelihood of a correct assignment in OUT. Scaling is described in more detail under HELP BAYES.

If MAXCHI = CHI, OMAXCHI contains the "tail-rejection" areas corresponding to the chi-square values for the class assignments. The values are scaled to lie in the range 0-255.


Restrictions: MAXCHI = CHI is only allowed if the 
              number of bands in IN is less than or 
              equal to 14.

OUTSTAT
Output statistics file. This contains statistics derived from the data in OUT and OMAXCHI including:


  -  A histogram of the # of pixels assigned to each 
     class
 
  -  For the maximum likelihood image, a histogram of 
     the scaled maximum likelihood values (0-255)

  -  For the chi-square image, a histogram of the 
     unmapped chi-square values (in the range 0-35) 
     scaled to the range 0-255, and 
  
  -  For each class, a histogram of the scaled 
     probability distribution for that class.  

NCLASS(-- )
Number of classes to be used in the classification. If default, all classes in the input statistics file are used. If NCLASS is greater than 0, the user will be prompted to select NCLASS classes from the input statistics file.

APRIORI(EQUAL)
Option for apriori probabilities. APRIORI allows the user to select different methods of specifying prior class probabilities.

If option ENTER is selected, the user is prompted for the prior probability of each class. These values will be stored in the input statistics file and the user will be informed by an output message. The given probabilities must sum to 1.0.

If option EQUAL is selected, then each class is assigned an equal prior probability; the reciprocal of the number of classes is the value used. No values will be stored in the statistics file.

If option SFILE is selected, the prior probabilities are obtained from the given statistics file.

MASKVAL(--)
Mask value--pixels for which all bands have this value will be assigned to MASK CLASS. Processing speed will be significantly increased for images with a large share of pixels that have values of MASKVAL for all bands.

MAXCHI(MAX)
Chi-square/likelihood image output file indicator. If MAXCHI = MAX, the second output file OMAXCHI will be an image with maximum likelihood values.

If MAXCHI = CHI, it will contain "tail-rejection" areas corresponding to the chi-square values for the class assignments.

Examples:

  1. LAS> bayes in=bay instat=bay out=bay.bayes omaxchi=bay.prob outstat=bayrec

    A Bayesian maximum likelihood classification is computed using the statistics in the statistics file BAY and the input image BAY. The classified image, maximum likelihood image, and statistics file are output as BAY.BAYES, BAY.PROB, and BAYREC, respectively.

  2. LAS> bayes in=bay instat=bay out=bay.class omaxchi=bay.chi outstat=bay.hst maxchi=chi

    BAYES performs a maximum likelihood classification on the input image, BAY, using the statistics file BAY, and produces an output classified image, BAY.CLASS, a chi-square image, BAY.CHI, and a statistics file, BAY.HST.

Description/Algorithm:

The Bayesian maximum likelihood classifier assumes that the probability distribution functions for each class are normal (Gaussian). Class membership (g) is calculated for each pixel vector as follows.

The pixel vector is a member of class m if


    g (x) > g (x) for all i = 1,...number of classes, i = m
     m       i                

(Reference:  Richard O. Duda and Peter F. Hart, "Pattern 
    Classification and Scene Analysis," 1973, p. 24.)

                           T  -1     
where  g (x) = Z -0.5(x-M ) C   (x-M )
        m       m        m   m      m    



where  Z = Ln P -0.5 Ln |C | -0.5N Ln (2 pi )
        m      m       	  m 

       N  = number of bands

       P  = class a priori probability
        m       

       C  = class covariance matrix
        m     
                            
       M  = class mean vector
        m   

       x = vector of values for a pixel to be classified

       m = class number

       |.| denotes the determinant

The covariance matrices and class mean vectors are retrieved from the statistics file associated with the multiband image. BAYES aborts if the required statistics are not available.

By default, each class is assigned an equal apriori probability of 1/NC, where NC is the number of classes. Alternatively, the user may enter a priori probabilities from the terminal. These are stored in the statistics file and may be accessed on subsequent runs of BAYES. Any a priori values entered from the terminal overwrite values currently in the statistics file.

The set of a priori probabilities must sum to unity. If the values entered do not meet this criteria, the user is given one more chance to enter a valid set of values before the program aborts.

The values of the classified image pixels correspond directly to the class numbers. If there are 32 classes, an intensity of 1 is assigned to class 1, 2 to class 2,...32 to class 32. This creates a very dark image, with little contrast.

The maximum likelihood values are scaled on output to form an image of integer values in the range 0-255. The assignment values gm(x) lie in the range MIN to LN(1). Using MIN=LN(0.29x10-38) the values are scaled as

OUTVAL(x)=(255*(MIN-gm(x)))/MIN

where OUTVAL(x) is the output integer value.

If a chi-square image is requested rather than a maximum likelihood image, the chi-square values are computed as


                             T  -1       
               X (x) = (x-M ) C   (x-M )
                m          m   m      m  


                     = 2(Z -g (x))
                          m  m    

The chi-square rejection values are restricted to lie in the range 0-35. The corresponding tail rejection areas are obtained from a chi-square table, which gives the tail rejection areas for chi-square values in the range 0-35 and degrees of freedom 1-14. These tail rejection areas (in the range 0-1) are scaled to lie in the range 0-255 to produce the output chi-square image. (Thus, a value of I in the chi-square image implies a confidence level of (1-I/255) in the classification).

An output statistics file is also produced and contains:


    o A histogram of the number of pixels assigned to each 
      class

    o For the maximum likelihood image, a histogram of the 
      scaled maximum likelihood values (0-255)

    o For the chi-square image, a histogram of the unmapped 
      chi-square values (in the range 0-35) scaled to the 
      range 0-255

    o For each class, a histogram of the scaled probability 
      distribution for that class

Using these data, the user may subsequently choose threshold levels for each class (using the program UNKNOWN). Any pixel whose likelihood/chi-square tail rejection value falls below this threshold is then assigned to an "unknown" class.

If the response to APRIORI is ENTER, the user is prompted for the a priori probabilities. Each class name is displayed and the user enters the appropriate a priori probability for the class.

Nonfatal Error Messages:

  1. [bayes-class] Statistics file has too many classes - first 255 will be used

    The input statistics file had more than 255 classes in it. Only the first 255 will be used for classification.

  2. [bayes-close] Error closing image files

    An error was encountered while trying to close image files. Contact system manager.

  3. [bayes-nclass] NCLASS is larger than the total number of classes, Number of classes to be used is now reset to: <xxxx>

    The user has specified more classes than are available in the statistics file. The program will reset the number of classes to the number listed in the statistics file.

  4. [bayes-retry] Prior probabilities do not sum to 1. You have one more chance.

    Re-enter prior probabilities at terminal so that they sum to 1.0.

Fatal Error Messages:

  1. [bayes-alloc] Error allocating dynamic memory

    An error was encountered when attempting to allocate dynamic memory. Contact system manager.

  2. [bayes-badprior] Sum of prior probabilities for selected classes is not equal to 1

    The sum of the prior probabilities for selected classes was not equal to 1. Check the input statistics file and correct the prior probabilities so that they sum to 1.

  3. [bayes-batch] Cannot run in batch when NCLASS is not equal to zero

    When the user specifies a value for NCLASS, he/she will be prompted to select which classes to use. Therefore the program cannot be run in batch. Rerun interactively to select classes.

  4. [bayes-covar] Covariance matrix has too few/too many values for class # <xxxx>

    The input statistics file was not created using an input image with the same number of bands as specified for IN. Regenerate statistics file for image with correct number of bands.

  5. [bayes-fatal] Fatal error encountered

    A fatal error was encountered during processing. The ouput file is deleted if $DELFLG="YES", and processing is terminated. The message displayed immediately preceding this error message specifies the error encountered.

  6. [bayes-mean] Mean vector does not have <xxxx> values for class # <xxxx>

    The input statistics file was not created using an input image with the same number of bands as specified for IN. Regenerate statistics file for image with correct number of bands.

  7. [bayes-noclass] No class name present in statistics file for class # <xxxx>

    No class name was present in the statistics file for specified class. Regenerate statistics file with class names.

  8. [bayes-nocovar] No covariance matrix present for class # <xxxx>

    No covariance matrix was present in the statistics file for specified class. Regenerate statistics file with covariance matrices.

  9. [bayes-nomean] No mean vector present for class # <xxxx>

    No mean vector was present in the statistics file for specified class. Regenerate statistics file with mean vectors.

  10. [bayes-noprior] No prior probability in statistics file for class # <xxxx>

    No prior probability was present in the statistics file for specified class. Regenerate statistics file with prior probabilities.

  11. [bayes-open] Error opening <xxxx> <xxxx> file

    An error was encountered opening specified file. Check to be sure that it exists and you have access to it.

  12. [bayes-size] Input images must be same size

    If more than one image is specified as input, they must be the same size. Check to be sure they are.

  13. [bayes-write] Error writing to <xxxx> <xxxx> file

    An error was encountered when trying to write to the specified file. Check to be sure that you have "write" access to it.

  14. [bayes-zcovar] Covariance matrix contains all zeroes for class # <xxxx>

    The covariance matrix for specified class contained only zeros. Regenerate statistics file.

User Notes:

  1. The classified image can be viewed directly on the display, but it is advised that the program CLASSMAP be used since it applies annotation and produces a more comprehensible image. The programs STRETCH, MAP, or RENUMBER may be run in order to increase the classified image's contrast.

  2. The output statistics file (OUTSTAT) can be listed using the program EDITSTAT's LIST command.

  3. The a priori probabilities (APRIORI) should be used with the default (EQUAL) unless the user has knowledge of the probabilities of the classes.

  4. The tail rejection percentage (P) can be obtained from the chi-square image gray level (G) from the relation:

    P = G/255 x 100