User's Guide

LOGICAL

Performs logical comparisons on input images

Function:

LOGICAL enables the user to make logical comparisons between image pixels and specified constants, producing an output image of user-specified true and false values. The user defines a logical expression to be evaluated and uses the input parameters to describe this expression to the program. LOGICAL accepts expressions that contain from one to ten logical comparisons.

Parameters:

IN
Input image(s). This is a list of the images to be used in the comparisons. The input data type may be BYTE, INTEGER*2, INTEGER*4, and REAL*4 data. Image names may appear more than once in the IN parameter if several comparisons are to be made with them. This repetition may be avoided by using the IMGSEQ parameter. Up to ten single band images may be specified. The input images may differ in both size and data type.

OUT
Output image. The data type of the output image is determined by the values specified in the parameters TRUEVAL and FALSEVAL. The default values specify the output to be a binary mask of zeroes and ones.

COMPVAL
Comparison values. Array of constants to be used in the logical comparisons, that is, the values with which each image's pixels will be compared. There must be one value for each input image.

IMGSEQ(--)
Image sequence. Array of integers showing the sequence in which the image names will be used. This is an optional parameter which allows the user to avoid repetition in the parameter IN.

Default: images are referenced in the order the names are entered.

LOGOPER(--)
Logical operator. Array of strings used to describe the type of logical comparison to be performed between each image and constant. One value must be entered for each image-to-constant comparison. Default: "EQ" for all entries.

  = EQ:   Equal to
  = NE:   Not equal to
  = LT:   Less than
  = GT:   Greater than
  = LE:   Less than or equal to
  = GE:   Greater than or equal to

LOGCON(--)
Logical connectors. Array of strings to be used in linking the set of comparisons into a logical expression. There is a LOGCON value between each logical comparison, so the number of entries in this array must be one less than the number of logical operators specified in the LOGOPER parameter. Default: "AND" for all entries.

  = AND:   Performs logical AND.
  = OR:    Performs logical OR.

CONORDER(--)
Order of logical connectors. Array of integers representing the order of priority in which to evaluate the logical connectors. The values in CONORDER act in a parenthesizing capacity for forming logical expressions. The number of entries in this array must be the same as for the LOGCON parameter. Default: the connectors are evaluated in sequence from the left of the logical expression to the right.

TRUEVAL(1.0)
Value for true expression. When the logical expression is evaluated as true, this value is assigned to the output pixel.

FALSEVAL(0.0)
Value for false expression. When the logical expression is evaluated as false, this value is assigned to the output pixel.

Examples:

  1. LAS> logical in = "image1 image2 image1 image1" out = outimage compval = (25 40 80 89) imgseq = (1 2 3 4) logoper = (lt lt gt lt) logcon = (and or and) conorder = ( 1 3 2) trueval = 1 falseval = 0

    Suppose that for all pixel locations the user wants a true result when the pixel values of IMAGE1 are less than 25 and when the pixel values of IMAGE2 are less than 40 and also wants a true result when the pixel values of IMAGE1 are between 80 and 89. Note that the first set of logical expressions is independent from the second set. Consequently, the output image will be true wherever either of these expressions is true. The following expresses this relationship in a logical algebraic manner:

    
          [(IMAGE1 < 25) AND (IMAGE2 < 40)] OR 
          [(IMAGE1 > 80) AND (IMAGE1 < 89)]
    

    The parameters of program LOGICAL are applied to this expression as follows:

    
        IN     =    "IMAGE1 IMAGE2 IMAGE1 IMAGE1"
        IMGSEQ =       1      2      3      4
    

    This specifies the image names that are used in the expression by their position from left to right. The same file names may be referenced by using:

    
        IN      =   "IMAGE1 IMAGE2"
        IMSEQ   =     1     2     1     1
        COMPVAL =    25    40    80    89
    

    These values are the constants to which the input pixels will be compared; i.e., IMAGE1 compared to 25, IMAGE2 compared to 40, IMAGE1 compared to 80, and IMAGE1 compared to 89.

    
        LOGOPER   =     LT    LT    GT    LT
    

    These values represent the comparison operation to be performed between each input image and its respective constant; i.e., IMAGE1 < 25, IMAGE2 < 40, IMAGE1 > 80, AND IMAGE1 < 89.

         
        LOGCON    =    AND    OR   AND
    

    This array specifies that logical connection desired between the comparisons described above. In this example, there are four logical comparisons to be performed between pixel values and constants, so there must be three logical connectors between them.

    
        CONORDER =    1    3    2
    

    This array represents the order of priority in evaluating the logical connections defined by the LOGCON parameter. The CONORDER parameter in essence establishes the parentheses in the logical algebraic equation. In this example, CONORDER indicates that the expression segment [(IMAGE1 < 25) AND (IMAGE2 < 40)] is to be evaluated first, the expression segment [(IMAGE1 > 80)] AND (IMAGE1 < 89)] will be evaluated second, and the results of these comparisons are to be evaluated third.

    Hence, to interpret the expression

           [(IMAGE1 < 25) AND (IMAGE2 < 40)] OR 
           [(IMAGE1 > 80) AND (IMAGE < 89)],
    

    The output image is mask of ones and zeros, where a "1" indicates that the input image pixels satisfied the logical expression and a "0" indicates that they did not.

  2. LAS> logical in = "image1 image3(:2) image3(:4)" out = outimage compval = ( 32 2 7) logoper = (lt gt eq) logcon = (or and) trueval = 200 falseval = 100

    This would evaluate the logical expression

          [(IMAGE1 < 32) OR (IMAGE3(:2) > 2)] AND 
           (IMAGE3(:4) = 7),
    

    where the images to be processed ar IMAGE1, a single-band image, and bands 2 and 4 of IMAGE3, a multi-band image. A value of 200 is assigned to every pixel in OUTIMAGE where the expression is true, and a value of 100 is assigned where the expression is false.

  3. LAS> logical in=(image1 "image3(:2)" "image3(:4)") out=outimage compval=(32 3 7) logoper= (lt gt eq) logcon=(or and) + conorder=(2 1) trueval=200 falseval=100

    This would evaluate the logical expression

                 (IMAGE1 < 32) OR [(IMAGE3(:2) > 2) AND 
                 (IMAGE3(:4) = 7)].               
    

    This is the same as the previous example except for the specification of CONORDER, which shifts the parentheses in the expression.

Description/Algorithm:

LOGICAL compares pixel values of images to user-supplied numeric constants, according to some user-supplied criteria. When all comparison criteria are satisfied for a given pixel, the corresponding pixel value in the output image is considered TRUE and is set to a default value of 1. If the comparison criteria are not satisfied for a given pixel, the corresponding pixel value in the output image is considered FALSE and is set to a default value of 0.

After receiving the input parameters and testing their validity, a one-time pass is made on the CONORDER and LOGCON values and an encoded string is built in Reverse Polish Notation (RPN). For each input pixel, an array of true/false values is created by evaluating each comparison in the input expression. This array is then referenced by the RPN-encoded string to determine the result of the expression, which then determines the value of the output pixel.

Nonfatal Error Messages:

    None.

Fatal Error Messages:

  1. [logical-imgseq] Number of values in COMPVAL and IMGSEQ must match

    The number of values in COMPVAL determines the number of comparisons. IMGSEQ must have the same number of values as COMPVAL.

  2. [logical-operator] Number of values in COMPVAL and LOGOPER must match

    The number of values in COMPVAL determines the number of comparisons. LOGOPER must have the same number of values as COMPVAL.

  3. [logical-connect] Number of values in LOGCON must be one less than that in COMPVAL

    The number of values in COMPVAL determines the number of comparisons. LOGCON must have one less value than COMPVAL.

  4. [logical-order] Number of values in CONORDER must be one less than that in COMPVAL

    The number of values in COMPVAL determines the number of comparisons. CONORDER must have one less value than COMPVAL.

  5. [logical-outval] TRUEVAL and FALSEVAL must have different values

    Specify different values.

  6. [logical-nbands] Only one band images are allowed

    Multi-band images are not allowed. Specify band option.

  7. [logical-seqval] IMGSEQ value exceeds number of input images

    The values in IMGSEQ must not exceed the number of input images.

Usernotes:

  1. It is recommended that the user specify explicitly the names of the files to be used in the program, allowing the optional parameter IMGSEQ to default. By doing this, a left to right reference is applied to the expression, making interpretation of the expression much simpler.

  2. The output data type is determined by the values of the parameters TRUEVAL and FALSEVAL and is set as follows:

          BYTE        if the output range is 0 through 255
          INTEGER*2   if the output range is -32768 through 
                      32767
          INTEGER*4   if the output range is -2147483648 
                      through 2147483747
          REAL*4      if the output range is greater than 
                      the INTEGER*4 range
                      or either TRUEVAL or FALSEVAL is a 
                      fractional value.