Use the Band Math tool to apply a mathematical operation, IDL function, or custom function to one or more bands in an image.

You can also write a script to perform Band Math using the PixelwiseBandMathRaster task.

The figure below depicts Band Math processing that adds three bands. Each band in the expression is mapped to an input image band, summed, and output as the resulting image data.

Follow these steps:

  1. From the Toolbox, select Band Algebra > Band Math. The Band Math dialog appears.

  2. Enter a mathematical operation or IDL function (including variable names) in the Enter an expression field. Here are some tips for entering an expression:

    • The input bands must have identical dimensions. The expression is applied on a pixel-by-pixel basis. Therefore, the input bands (to which your expression is applied) must all have the same spatial dimensions in rows and columns. The Band Math tool does not automatically coregister images that are georeferenced.
    • Use IDL syntax; for example:

      (float(b1)+float(b2)+float(b3))/3.0

      See IDL Tips for Use with Band Math for more information.

    • If the expression involves an IDL function (result = expression), enter only the expression part of the function.

      Incorrect: result = SMOOTH(b1, 9)

      Correct: SMOOTH(b1, 9)

    • All variables in the expression must be named Bn or bn, where n can be up to be five characters long. For example, all of the following expressions are valid when adding three bands:
    • b1 + b2 + b3
      B1 + B11 + B111
      B1 + B2 + B3
    • The expression must produce a result with the same spatial dimensions in rows and columns as the input bands.
  3. Optionally use the following functionality:
    • Previous Band Math Expressions: This list shows previously applied mathematical expressions. To apply an expression to a new set of bands, select it from the list and enter it in the Enter an expression field. Click OK.
    • Save: Save mathematical expressions to a file. The Save Expressions to a File dialog appears. Enter an output filename with an .enp extension. Click OK. You can save expressions to a file without having to first run them through the Band Math tool.
    • Clear: Clear all expressions from the Previous Band Math Expressions list.
    • Delete: Delete a single expression from the Previous Band Math Expressions list.
    • Add to List: To add an expression to the Previous Band Math Expressions list, enter it in the Enter an expression field and click Add to List.
  4. Click OK. The Variables to Bands Pairings dialog appears. Use this dialog to assign bands to variable names that you entered in the Enter an expression field. The remaining steps use the expression (float(b1)+float(b2)+float(b3))/3.0 as an example.
  5. In the Variables used in expression field, select the variable B1 - [undefined].
  6. Select the band that you want to represent B1, from the Available Bands List. When the first band is selected, only those bands with the same spatial dimensions are shown in the band list.
  7. Continue to assign a value to B2, B3, and so forth in the same manner.
  8. Select output to File or Memory.
  9. Perform optional spatial subsetting.
  10. Enter an Output Filename.
  11. Click OK. The Band Math image is added to the display and to the Layer Manager.

Another option is to assign an entire multi-band image as one or all of the variables:

  1. In the Variables to Band Pairings dialog, select a variable and click Map Variable to Input File.
  2. Select an input file and perform optional spectral subsetting, then click OK.
  3. Continue to assign a value to b2, b3, and so forth in the same manner. If more than one file is used, they must have the same number of bands.

See Also


IDL Tips for Use with Band Math, Band Math User Functions, ENVI Modeler Example: Using Conditional Operators with Rasters, Spectral Indices, Spectral Math, Band Ratios