Application Tips for ENVI 5.0 – Building a mask from a classified image

This post is part of a series on getting the most out of your geospatial applications. Check back regularly to see the latest tips and examples.

Objective: Utilize one or more classes from a classified image to generate a mask in ENVI 5.0, such that the mask can then be utilized to exclude selected areas from further analysis or display.

Scenario: For this tip we utilize a coral reef scene where the goal is to mask clouds from areas containing water and submerged habitat. In this example, as an approximation, an unsupervised classification has been used to segment the image into 20 classes, where 9 of the 20 classes have been visually identified as containing clouds.


The Tip: Below are steps that can be used to transform this classification output into a cloud mask:

  • From the ‘Toolbox’, select Raster Management > Masking > Build Mask [In ENVI Classic this same command is found under Basic Tools > Masking > Build Mask]
  • In the ‘Build Mask Input File’ dialog, select the classification output file from which you will be building the mask, and then select OK
  • In the ‘Mask Definition’ dialog, select Options > Import Data Range…
  • In the ‘Select Input for Mask Data Range’ dialog, select the same classification output file that was selected as the basis for the mask, and then select OK
  • In the ‘Input for Data Range Mask’ dialog, enter the minimum and maximum values corresponding to the relevant classes that contain clouds, and then select OK.


  • In our example the cloud classes all happen to be contiguous, however, in many situations this is not the case. When this occurs, simply repeat the process for selecting the minimum and maximum values until all classes have been selected. To do so, from the ‘Mask Definition’ dialog, select Options > Import Data Range… , enter the appropriate minimum and maximum values in the ‘Input for Data Range Mask’ dialog, and then select OK. A theoretical example is shown below.


  • Note that masks can also be defined using a number of other sources, such as ROIs, shapefiles, annotations and other data ranges.
  • Once all of the classes have been selected, make sure the clouds are set to ‘off’ (i.e., cloud values will be zero in the mask). In the ‘Mask Definition’ dialog, select Option > Selected Areas “Off”
  • As the final step, in the ‘Mask Definition’ dialog, enter an output filename (or select the option to output result to memory) and then select Apply.
  • The result is a mask that can be used to remove clouds from the image and/or exclude them from further analysis.


As a parting thought, it can be observed in this example that the final cloud mask is incomplete, in that it does not include cloud shadows and fails to completely encompass all the cloud areas. This is not a result of the mask process, but rather a function of using an abbreviated unsupervised classification to identify the cloud areas, which was done only for the purposes of this example. If a more complete cloud mask is desired, a greater number of classes can be used in the unsupervised classification to further segment the image, or other algorithms can be used that are specifically designed for the detection of clouds and cloud shadows.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s