User's Guide

MATH

Performs mathematical functions on two images.

Function:

Allows the user to perform the following mathematical operations with images of a specified size and data type:

   ADD   Adds two input images together to form a 
         single output image.
   AND   Performs a bitwise logical "and" of two 
         images.
   DIV   Divides one image by another with a scaling 
         factor.
   MAX   Generates an image consisting of the maximum 
         of two images.
   MIN   Generates an image consisting of the minimum 
         of two images.
   MUL   Multiplies two images together.
   OR    Performs a bitwise "or" of two images.
   SUB   Subtracts two images to form a third.
   XOR   Performs a bitwise "exclusive or" on two 
         images.

Parameters:

Subcommand -MAX:
Performs a "maximum" of two images. The input images are compared with the maximum value being used for output.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)
Subcommand -MIN:
Performs a "minimum" of two images. The input images are compared with the minimum value being used for output.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)
Subcommand -ADD:
Adds two images. The two input images are added with scale factor and offset factor options.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)

SCALFACT(1,1)
Scale factor for images. The scale factors to be applied to both input images, respectively.

OFFSET(0.0)
Offset to be applied. The additive offset applied to the image after the input images have been added.
Subcommand -SUB:
Subtracts two images. The two input images are subtracted with a scale and an offset factor optional.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)

SCALFACT(1,1)
Scale factor for images. The scale factors to be applied to both input images, respectively.

OFFSET(0.0)
Offset to be applied. The additive offset applied to the image after the input images have been subtracted.
Subcommand -DIV:
Divides two images. The first image is divided by the second image and then the scale and offset factors are applied.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)

SCALFACT(1.0)
Scale factor applied. The scale factor to be applied after the images are divided.

OFFSET(0.0)
Offset to be applied. The additive offset applied to the image after the input images have been divided.

PIXVAL(1.0)
Pixel value. The pixel value to be inserted into the output location whenever division by zero is encountered.
Subcommand -MUL:
Multiplies two images. The first image is multiplied by the second image and then the scale and offset factors are applied.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)

SCALFACT(1.0)
Scale factor applied. The scale factor to be applied after the images are multiplied.

OFFSET(0.0)
Offset to be applied. The additive offset applied to the image after the input images have been multiplied.
Subcommand -AND:
Performs a "bitwise and." A logical "and" is applied on a bit-by-bit basis.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)
Subcommand -OR:
Performs a "bitwise or." A logical "or" is applied on a bit-by-bit basis.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)
Subcommand -XOR:
Performs an "exclusive or." A logical "exclusive or" is applied on a bit-by-bit basis.

IN
Input images. Allowed data types are BYTE, INTEGER*2, INTEGER*4, and REAL*4. Window and/or band options may also be specified.

OUT
Output image. Created by performing the specified operation. The output data type is determined by the ODTYPE parameter.

ODTYPE(SAME)
Output data type. The data type of the output image.

  = SAME:  Same as input 
  = BYTE:  BYTE      (8-bit unsigned integer)
                     (0 through 255)
  = I*2:   INTEGER*2 (16-bit signed integer)
                     (-32768 through 32767)
  = I*4:   INTEGER*4 (32-bit signed integer)
                     (-2147483648 through 2147483647)
  = R*4:   REAL*4    (32-bit signed real)
                     (System dependent)

Examples:

  1. LAS> math-add in="a(1,1,30,30) b(20,20,30,30)" out=c scalefact=(5.0 4.0) offset=10.0

    The pixel values in the window of the input image A are scaled by a factor of 5 and added to the pixel values in the window of the input image B, which are scaled by a factor of 4. The pixels of the resultant image are offset by a value of 10 to create the output image C. If A and B are multi-band images, the number of bands in C is equal to the minimum number of bands contained in either A or B. The size of the output image C is 30 x 30.

  2. LAS> math-and in="a(1,1,30,30) b(20,20,30,30)" out=c

    A logical "and" is performed on the pixel values in the two windowed input images to generate the output C. The number of image bands in C is equal to the fewest number of bands in A or B. The size of the output image C is 30 x 30. The output bit value equals 0 if either compare bit values equal 0; otherwise, the output bit value equals 1.

             If   IN1 value = 11011011     If   IN1 value = 11011011
             and  IN2 value = 00100100     and  IN2 value = 00110010
             then OUT value = 00000000     then OUT value = 00010010
    

  3. LAS> math-div in="a(l,l,30,30) b(20,20,30,30)" out=c scalfact=5.0 0ffset=10.0 pixval=0.0

    The pixel values in the window of the input image A are divided by the pixel values in the window of the input image B. This resultant image, C, is scaled by a factor of 5 and offset by a value of 10. If a pixel value of B is 0, a value of 0 will be inserted in C. The number of bands in C is equal to the fewest number of bands contained in A or B. The size of the output image C is 30 x 30.

  4. LAS> math-max in="a(1,1,30,30) b(20,20,30,30)" out=c

    A "maximum" is performed on the pixel values in the two windowed input images to generate output C. The number of image bands in C is equal to the fewest number of bands in A or B. The size of the output image C is 30 x 30.

  5. LAS> math-min in="a(1,1,30,30) b(20,20,30,30)" out=c

    A "minimum" is performed on the pixel values in the two windowed input images to generate output C. The number of image bands in C is equal to the fewest number of bands in A or B. The size of the output image C is 30 x 30.

  6. LAS> math-mul in="a(l,l,30,30) b(20,20,50,50)" out=c scalfact=5.0 offset=l0.0

    The pixel values in the window of A are multiplied by the pixel values in the window of B, and the result is scaled by a factor of 5. This product is offset by a value of l0 to create the output image C. The number of bands in C is equal to the minimum number of bands contained in A or B. The size of the output image C is 30 x 30.

  7. LAS> math-or in="a(l,l,30,30) b(20,20,30,30)" out=c

    A logical "or" is performed on the input pixel values for the windowed input images to generate the output image C. The number of bands in C is equal to the minimum number of bands contained in A or B. The size of the output image C is 30 x 30. The output bit value equals 1 if either compare bit values equal 1; otherwise, the output bit value equals 0.

             If   IN1 value = 11011011    If   IN1 value = 11011011 
             and  IN2 value = 00100100    and  IN2 value = 00110010 
             then OUT value = 11111111    then OUT value = 11111011
    

  8. LAS> math-sub in="a(1,1,30,30) b(20,20,30,30)" out=c scalefact=(5.0 4.0) offset=10.0

    The pixel values in the window of the input image B are scaled by a factor of 4 and subtracted from the pixel values in the window of the input image A, which are scaled by a factor of 5. The pixels of the resultant image are offset by a value of 10 to create the output image C. If A and B are multi-band images, the number of bands in C is equal to the minimum number of bands contained in A or B. The size of the output image C is 30 x 30.

  9. LAS> math-xor in="a(l,l,30,30) b(20,20,30,30)" out=c

    An "exclusive or" is performed on the pixel values in the two windowed input images to generate output C. The number of members in C is equal to the minimum number in A or B. The output bit value equals 0 if both compare bit values are 1; otherwise, the output value equals 1.

             If   IN1 value = ll0ll0ll    If   IN1 value = ll0ll0ll
             and  IN2 value = 00l00l00    and  IN2 value = 00ll00l0
             then OUT value = 11111111    then OUT value = 11101001
    

    The size of the output image C is 30 x 30.

Description/Algorithm:

MATH has nine options within it to perform various mathematical computations against images. They each generate an image on a pixel-by-pixel basis for all bands in the input image.

MATH-ADD has the following algorithm:

     OUT(i,j) = SF1 * IN1(i,j) + SF2 * IN2(i,j) + OFFSET


MATH-AND has the following algorithm:

     OUT(i,j) = IN1(i,j) .AND. IN2(i,j)


MATH-DIV has the following algorithm:

     If IN2 <> 0:
     OUT(i,j) = (SCALFACT * (IN1(i,j)/IN2(i,j))) + OFFSET

     If IN2 = 0:
     OUT(i,j) = PIXVAL


MATH-MAX has the following algorithm:

     OUT(i,j) = MAX(IN1,IN2)


MATH-MIN has the following algorithm:

     OUT(i,j) = MIN(IN1,IN2)


MATH-MUL has the following algorithm:

     OUT(i,j) = (SCALFACT * (IN1(i,j) * IN2(i,j))) + OFFSET


MATH-OR has the following algorithm:

     OUT(i,j) = IN1(i,j) .OR. IN2(i,j)


MATH-SUB has the following algorithm:

     OUT(i,j) = SF1 * IN1(i,j) - SF2 * IN2(i,j) + OFFSET


MATH-XOR has the following algorithm:

     OUT(i,j)=IN1(i,j) .XOR. IN2(i,j)

where (i,j) is a pixel location.

Nonfatal Error Messages:

  1. [math-bands] Images do not have the same number of bands

    The input images do not contain the same number of bands. The number of output bands will be equal to the smaller of the two input image bands.

Fatal Error Messages:

  1. [math-lines] Images do not have the same number of lines

    The number of lines for the specified images are different for the corresponding IN elements.

  2. [math-samples] Images do not have the same number of samples

    The number of samples for the specified images are different in the corresponding IN elements.

  3. [math-alloc] Error allocating dynamic memory

    An error occurred while allocating dynamic memory for processing.

  4. [math-comp] Can't do an R*4 bitwise comparison

    A bitwise comparison was attempted on a R*4 data type.

  5. [math-gettyp] Error attempting to get data type

    c_gettyp did not successfully retrieve the input image type.

User Note:

  1. When conversions from a large to smaller data type are performed, check the output pixels for validity.