User's Guide

MASKSTAT

Calculate class statistics of multispectral images via a classified image mask.

Function:

Uses a classified input image (or "mask") to collect pixels according to class from an input data image and produces an output statistics file containing statistics for each class.

Parameters:

MASKIMG
Input classified image. It must be a single-band byte image. If the user has run UNKNOWN on this image, it may contain 0 or 255 for the UNKNOWN class. These classes will be ignored in making the statistical calculations.

IN
Input image. Specifies the input multispectral image for which class statistics will be computed.

OUTSTAT
Output statistics file. The class statistics stored in OUTSTAT are:

   MEAN_VECTOR
   COVARIANCE_MATRIX
   HISTOGRAM for each input band
   NPOINTS (# points in class)

Examples:

  1. LAS> maskstat maskimg=class in=image outstat=mask;stats

    The mean vector, number of points, covariance matrix, and histogram for each class are calculated and placed in MASK.STATS. Classes are obtained from CLASS. The area in the multispectral image IMAGE from which statistics are taken is given by the size of CLASS.

  2. LAS> maskstat maskimg="class.dat(1,1,128,128)" in=mult.image outstat=corner;stat

    Statistics are computed from the upper-left corner of images defined by the input image MULT.IMAGE and output to CORNER;STAT.

  3. LAS> maskstat maskimg="out.class(1,1,10,10)" in="dc(500,500,10,10)" outstat=dc;stat

    Statistics are computed for the 10 x 10 area in DC beginning at SL=500, SS=500 according to the classes given in the upper-left corner of OUT.CLASS.

Description/Algorithm:

MASKSTAT obtains the class (a number between 0 and 255) of a pixel from the input classified image. The value of a pixel at the same location in the input image is obtained and used in the statistical computations for that class. The mean vector, covariance matrix, number of pixels, and histogram of each class are calculated for the input image and written out to a statistics file. The area for which statistics are computed is determined by the intersection of the size or windowed size of the input classified image and the input image.

If the program UNKNOWN has been previously run on the input classified image, pixels having unknown class may have been set to 0 or 255 in the classified image. Statistics are not computed for these pixels.

MASKSTAT calculates the following statistics:

  o  Number of pixels in each class
  o  Class mean vectors
  o  Class covariance matrices
  o  Class histograms for each band

Statistics are calculated using an iterative technique adopted from B. P. Welford, "Note on a method for calculating corrected sums of squares and products," Technometrics, vol. 4, no. 3, 1962, pp. 419-20, as follows:

            N
             a
           SUM  x
                 i,m
           i=1
   X    =  ---------------------
    m               N
                     a

            N
             a     i (         SUM   x     ) (         SUM  x    )
           SUM    ---(         j=1    j,k  ) (         j=1   j,m )
           i=2    i-1( x    -  ----------- ) ( x    -  --------- )
                     (  i,k           i    ) (  i,m        i     )
   C    =  ---------------------------------------------------
    k,m                           N  - 1
                                   a
This iterative procedure for calculating the covariances is more precise than traditional one-pass procedures, since it avoids the accumulation of very large sums and the subtraction of two very large numbers close together in value. The technique, therefore, is highly suitable for image data where there may be very large numbers of pixels in a single class.

The program writes to the output statistics file the class names, number of data points, mean vectors, covariance matrices, and histograms.

Nonfatal Error Messages:

    None.

Fatal Error Messages:

  1. [maskstat-mltbnd] Multiple bands not allowed for MSKIMG

    MASKIMG may not contain more than one band. If the user desires to run a set of bands against more than one classified image, MASKSTAT may be run repeatedly.

  2. [maskstat-class] MASKIMG must be a classified image

    Only integer values between 0 and 255 are appropriate for a classified image.

  3. [maskstat-inbyt] Input image must be byte image

    The data type of the input images or class must be BYTE, and may be changed by first running CONVERT.

User Notes:

  1. This program usually will be used after the programs MASK, ISOCLASS, BAYES, etc. The program KMEANS will run MASKSTAT if the user sets STATS=YES (see KMEANS).

  2. EDITSTAT may be used to display the output statistics file.

  3. A typical processing sequence would be to run ISOCLASS to produce a classified image, use MASKSTAT to produce the statistics file, and run EDITSTAT to obtain its listing. (Note: A histogram is produced for each class, so bulky printout will result if the number of classes is large.)