Create and Apply Masks
Lesson 1 of 1
Create and Apply Masks
Before doing any spectral analysis or image processing, you can choose to mask pixels in an image so that they do not influence the analysis results. Masked pixels will be displayed as transparent in the resulting image (called a masked raster).
Sample Data
Download sample data for this quick guide below. Then extract the contents of the .zip file to a local directory.
[Landsat8_France.zip
51.8 MB
DownloadArrow down with horizontal line beneath it](assets/Landsat8_France.zip)
Open the Multispectral Image
- 1
Select File > Open from the Menu bar. An Open dialog appears. 2. 2
Go to the location where you saved the data, and select the file Landsat8_France.dat. 3. 3
Click Open. The image is added to the Layer Manager and displayed in the Image window. 4. 4
In theLayer Manager, right-click on Landsat8_France.dat and select Zoom To Layer Extent.

Creating a Mask
You can create a mask from a Region of Interest (ROI), from a shapefile, by creating binary rasters, or by using options available in the Build Raster Mask tool. This section describes the use of ROIs to create a masked raster.
Regions of Interest (ROIs)
A common scenario is to create ROIsto define pixels that you want to include or exclude from image processing. Follow these steps to create a mask from ROIs. You will not see the binary mask; ENVI creates it internally and applies it to the input image.
- 1
Select File > New > Region of Interest from the Menu bar.Or, select the Region of Interest (ROI) Tool in the Toolbar.


- 2
In the ROI Tool dialog, select the Threshold tab. 2. 3
Name the new ROI "Clouds" in the ROI Name field. Press the Enter key to accept the new name. 3. 4
Click the Add New Threshold Rule button.

- 5
In the Data Selection dialog, select the "SRB7" band and click OK. The Choose Threshold Parameters dialog appears.
The dialog displays a histogram of data values in the SRB7 band, which is a shortwave-infrared (SWIR) band. The Landsat image covers a mountainous area that contains snow at the highest elevations. Clouds and snow are difficult to separate in visible bands because they both exhibit high reflectance. SWIR wavelengths are more effective at separating clouds from snow.
In the steps that follow, you will select a range of data values to mask out. You can interactively do this by sliding the left (minimum) and right (maximum) vertical bars back and forth while enabling the Preview option, or you can manually enter minimum and maximum pixel values. You will do the latter in the next step. 2. 6
Enter the following values in the fields provided. Press the Enter key after each entry.
Min Value: 0.3
Max Value: 0.72

This identifies the highest reflectance values in the SRB7 band, which fall along the tail of the histogram.
- 7
Click OK to dismiss the Choose Threshold Parameters dialog. 2. 8
From the Region of Interest (ROI) Tool menu bar, select File > Save As and save the ROI to .xml format.
Applying the Mask
- 1
From the Menu bar, selectFile > Save As > Save As (ENVI, NITF, TIFF, DTED). The Data Selection dialog appears. 2. 2
Select Landsat8_France.dat and click the Maskbutton near the bottom. The Mask Selection dialog appears. 3. 3
Select the Clouds ROI. 4. 4
Enable the Inverse mask option. This will exclude pixels inside the ROI from subsequent analysis.

- 5
Click OK to dismiss the Mask Selection dialog, then OK to dismiss the Data Selection dialog. The Save File As Parameters dialog appears. 2. 6
Leave the output format as ENVI. 3. 7
In the Data Ignore Value field, enter a value of 0. 4. 8
Enter an output file name of your choice. 5. 9
Click OK. When processing is complete, the masked image is added to the Layer Manager and displayed in the Image window. 6. 10
In the Layer Manager, uncheck the Landsat8_France.dat layer to hide it. 7. 11
Use the Cursor Value tool to verify that the masked pixels are labeled "No Data".

Some cloud pixels are still left, but we removed the brightest of them. You can also try adding multiple band thresholds or run a supervised classification to label them all.
This concludes the Quick Guide.
Your input is important to us, please take a few moments to fill out ourQuick Guide Feedback(opens in a new tab)form.
© 2025 NV5 Geospatial Solutions, Inc. This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR).