Use the Calculate Cloud Mask Using Fmask tool to create a cloud mask for the following sensors:

  • Landsat 4-5 TM
  • Landsat 7 ETM+
  • Landsat 8
  • Sentinel-2 Level-1C
  • NPP VIIRS Moderate Resolution (750 m) reflectance and brightness temperature SDR data downloaded from NOAA CLASS (HDF5 format)

ENVI uses the Fmask algorithm cited in the References section below.

You can also write a script to calculate a cloud mask for Landsat using the CalculateCloudMaskForProduct task.

Before You Begin


The input image must contain multispectral bands within the following wavelength ranges:

  • Blue: 0.45 - 0.523 µm
  • Green: 0.52 - 0.605 µm
  • Red: 0.63 - 0.69 µm
  • NIR: 0.75 - 0.9 µm
  • SWIR1: 1.55 - 1.75 µm
  • SWIR2: 2.05 - 2.380 µm

If the image has thermal and cirrus bands, these will improve the accuracy of the cloud mask result. The thermal band must range from 10.4 to 12.5 µm. Landsat 8 provides a separate band group with two thermal bands. When both are present, ENVI uses Thermal Infrared (TIR) Band 1 (10.9 µm) for cloud mask generation. If you provide a spectral subset with only one thermal band, it will use that band for cloud mask generation. Landsat 8 OLI and Sentinel-2A sensors also have cirrus bands. The cirrus band must range from 1.36 to 1.385 µm.

ENVI will automatically calibrate the multispectral and cirrus bands (if available) to top-of-atmosphere reflectance while generating the cloud mask. It will calibrate the thermal band (if available) to brightness temperatures. You do not need to perform radiometric or thermal calibration separately.

Open Files


  1. Select File > Open from the menu bar.
  2. In the Open dialog, select the data file.
    • Select a *_MTL.txt metadata file for a Landsat 4-5 TM, Landsat 7 ETM+, or Landsat 8 dataset.
    • Select an S2A_*.xml file for a Sentinel-2 dataset.
    • Select an .h5 file for NPP VIIRS data.

NPP VIIRS

The cloud mask tool supports NPP VIIRS Moderate Resolution (750 m) reflectance and brightness temperature SDR data downloaded from NOAA CLASS (HDF5 format). After you select an .h5 file, the Select NPP VIIRS Parameters dialog appears. Follow these steps to continue:

  1. From the Select Product drop-down list, select Reflectance/Thermal.
  2. Select the Geocorrect and Mitigate Bowtie Effect option to georeference the source imagery, which will also remove any bowtie artifacts. Georeferencing is only available if the file you selected has Latitude and Longitude bands. A Quality band is further needed to perform bowtie correction.
  3. The default Projection Type is Geographic WGS-84. Choose Polar Stereographic WGS-84 if the imagery covers the polar regions.
  4. Select an Interpolation Method. The GLT algorithm establishes a regular output grid and finds the best location for each source image pixel. Any output grid point for which a source pixel could not be found will be filled with one of the following methods:
    • Distance Weighted (default): A distance-weighted average of the surrounding valid values. Use this method to create an image with the fewest visible interpolation artifacts.
    • Nearest Neighbor: Select this method when the set of valid pixel values cannot be modified, for example, when values represent the integral values of a classification.
  5. Select an output directory for the georeferenced and bowtie-corrected image.
  6. Disable the Display Geocorrected Image option.
  7. Click OK. The Process Manager in the lower-right corner of the ENVI application shows the processing status of GLT reprojection. This process occurs twice: once for the reflectance dataset and another for the brightness temperature dataset.

Create a Cloud Mask


  1. From the Toolbox, select Feature Extraction > Calculate Cloud Mask Using Fmask Algorithm.
  2. Click the Browse button next to the Input Rasters field.
  3. In the Data Selection dialog, click the Select All button to select all datasets that are listed for your Landsat, Sentinel-2, or NPP VIIRS file.
  4. Click OK.

Set Parameters

  1. For the Kernel Size field, specify the number of pixels along one side of a square kernel. The default value is 7 (to create a 7 x 7 array). Cloud regions are dilated by this kernel size before output.
  2. For the Cloud Probability Threshold field, specify a threshold for cloud probability over clear-land and clear-water regions. The default value is 22.5.
  3. Select an output filename and location for the cloud mask raster.
  4. Enable the Display result check box to display the output in the view when processing is complete. Otherwise, if the check box is disabled, the result can be loaded from the Data Manager.
  5. To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow and select Save Parameter Values, then specify the location and filename to save to. Note that some parameter types, such as rasters, vectors, and ROIs, will not be saved with the file. To apply the saved task settings, click the down arrow and select Restore Parameter Values, then select the file where you previously stored your settings.

  6. To run the process in the background, click the down arrow and select Run Task in the Background. If an ENVI Server has been set up on the network, the Run Task on remote ENVI Server name is also available. The ENVI Server Job Console will show the progress of the job and will provide a link to display the result when processing is complete. See ENVI Servers for more information.

  7. Click OK. When processing is complete, the cloud mask is displayed and added to the Layer Manager. The cloud mask is a binary image where cloud (masked) pixels have values of 0 and non-cloud (non-masked) pixels have values of 1.
  8. Right-click on the cloud mask in the Layer Manager and select Zoom to Layer Extent to view the entire mask.

Apply the Cloud Mask to the Multispectral Source Image


  1. From the menu bar, select File > Save As > Save As (ENVI, NITF, TIFF, DTED).
  2. In the Data Selection dialog, select the multispectral dataset to which to apply the cloud mask. Do not click OK yet.
  3. Click the Mask button.
  4. In the Mask Selection dialog, select the cloud mask raster. If it is not listed in the Data Selection dialog, click the Open button and navigate to where you saved the cloud mask raster on disk.
  5. Click OK in the Mask Selection dialog, then click OK.
  6. In the Save File As Parameters dialog, select an output format. The choices are NITF, ENVI, or TIFF.
  7. Select an output filename and location for the masked image.
  8. Enable the Display result check box to display the output in the view when processing is complete. Otherwise, if the check box is disabled, the result can be loaded from the Data Manager.
  9. Click OK.

When processing is complete, the masked cloud pixels are set to values of NoData in the displayed image. You can use this mask raster for any subsequent image processing. If you will perform spectral analysis on the data, you should correct for atmospheric effects next by using the QUick Atmospheric Correction (QUAC) tool.

The ENVI header file for the cloud mask will contain a new cloud cover field with the reported percentage of cloud cover. You can also view the cloud cover percentage by right-clicking on the cloud mask file in the Layer Manager, selecting View Metadata, and clicking the Image Parameters node.

References


ENVI uses the Fmask algorithm cited in the following references:

Zhu, Z., S. Wang, and C. E. Woodcock. "Improvement and Expansion of the Fmask Algorithm: Cloud, Cloud Shadow, and Snow Detection for Landsats 4-7, 8, and Sentinel 2 Images." Remote Sensing of Environment 159 (2015): 269-277, doi:10.1016/j.rse.2014.12.014 (paper for Fmask version 3.2).

Zhu, Z., and C. E. Woodcock. "Object-Based Cloud and Cloud Shadow Detection in Landsat Imagery." Remote Sensing of Environment 118 (2012): 83-94, doi:10.1016/j.rse.2011.10.028 (paper for Fmask version 1.6).