Masthead

Image Thresholding & Masking

Thresholds

Image thresholding is a simple form of image segmentation. It is a way to create a binary image from a single band or multi-band image. The process is typically done in order to separate "object" or foreground pixels from background pixels to aid in image processing.

In this process, a threshold level is selected where all pixel values below the threshold are mapped to zero (black) and an upper threshold value is chosen so that all pixel values above this threshold are mapped to 255 (white). The thresholding process can be used to create binary masks for an image.

threshold

Masks

Masks are used to exclude certain pixels from image processing or when computing image statistics. Masks are used to exclude certain pixels from image processing or when computing image statistics. Masked pixels aren't visible (they are transparent) when displayed. A mask is a binary raster that contains pixel values of 0 and 1, for example:

Before doing analysis or image processing, you may want exclude certain pixels from the analysis so that they do not influence the results. Some examples include: excluding water and cloud pixels from vegetation analysis, excluding bad data values before computing image statistics or excluding pixels outside of a geographical area of interest. Masks are often created using thresholds to isolate specfic pixel values. Mask can also be created from vectors (for example, a shapefile). An example would be masking pixels outside of a city or forest boundary.

Cloud Masks and Compositing

Clouds can present a significant challenge when working with remote sensed data. Extreme cloud cover and shadows can make the data in those areas difficult if not impossible to analyze. These areas can simply be masked or removed from the processing by creating a mask that targets clouds. Many software packages have automatic cloud detection algorithms to aid in identifying and masking clouds. Cloud free imagery can be created through compositing or using multple images to create one cloud free image. In this process cloud masks are created to remove areas of the image with clouds. Pixel data from another image where no clouds were present in that location are used in those areas.

 

Cloud Mask

Data Ignore or NoData Value

When you create a masked raster, you must specify a data ignore (ENVI terminology) or NoData (ArcGIS terminology) value. A data ignore or NoData value is a designated pixel value that programs ignore when processing an image or computing statistics. The data ignore value often represents the absence of data in a pixel. There also may be uniform areas in a raster that the you do not want to display. These can include borders, backgrounds, or other data considered to not have valid values. Sometimes the default data ignore value is set to 0, but in many cases a pixel value of 0 is a valid measurement. For example a raster could be storing precipitation data and a value of 0 simply indicates no rain and therefore is a valid value. The point of a data ignore value is to have a specific value set aside to mark masked pixels, or pixels to ignore. If you choose a value that is already used, you risk ignoring good pixels. A data ignore (NoData) should be a value that you are certain is not used in any of the valid pixels in the image. For example, -9999 is a common value for storing NoData as it is highly unlikely that -9999 is a valid data value.

Data Ignore ValuesIn the Landsat image on the left the data ignore value is set incorrectly, on the right it properly set and the borders around the images are not being displayed.

 

 

← Back

Next →

Module Home





Contact Info

Humboldt State University
1 Harpst Street Arcata, CA 95521
skh28@humboldt.edu

© Copyright 2020 HSU - All rights reserved.