Mask

Masking is a critical processing step in satellite image analysis. It involves excluding specific areas from further processing to focus on regions of interest or remove unwanted data. A common application is cloud masking, where cloud-covered areas are excluded before evaluating surface features. Masks in satellite data typically come in three formats:

  1. Threshold Mask

    A threshold mask uses continuous data values, such as reflectance or probability, to generate a binary mask.

    How It Works: A threshold value is set, and pixels that meet the condition (e.g., below or above the threshold) are included in the mask. Example Usage: Removing low-confidence pixels or separating land from water based on reflectance values. Output: A binary mask where pixels are either included (1) or excluded (0) based on the threshold.

  2. Bitmap Mask

    A bitmap mask encodes multiple masking criteria into a single layer using bit-level representation.

    How It Works: Each bit in a pixel value represents a specific condition or category. For example:

    Bit 0: Clouds

    Bit 1: Water

    Bit 2: Snow

    Bit 3: Vegetation health

    A single pixel can represent multiple criteria simultaneously by combining bits.

    Common Applications: Frequently used in satellite band quality or classification layers where various conditions are stored compactly. Allows for filtering based on individual or combined criteria.

    Output: A mask that can be decoded to extract individual categories, e.g., isolating cloud-covered areas. Example: An 8-bit bitmap can store up to 8 masks, making it highly efficient for storing complex classifications.

  3. Value Mask

    A value mask assigns discrete categorical values to pixels, where each value represents a single, mutually exclusive class. Unlike bitmap masks, a pixel can belong to only one class at a time.

    How It Works: Each pixel stores an integer value corresponding to a predefined class label. Classification algorithms (e.g., supervised or unsupervised classifiers) assign one class per pixel based on spectral, temporal, or contextual information. Example class encoding:

    0: No data

    1: Water

    2: Urban

    3: Forest

    4: Agriculture

    5: Clouds

    Common Applications: Land cover and land use classification Thematic maps (forest type, crop type, impervious surface) Semantic segmentation outputs from machine learning models Scene classification products in remote sensing

When working with satellite images and their associated masks, it's essential to process the images and masks separately before applying the mask method.

Parameters¤

Name Type Description
input_dir str Specify the directory containing the satellite images and the mask files. This directory can have a hierarchical structure with GeoTIFF files. The files have to contain a date string in their names. The date is used to match the mask with the images.
output_dir str The output directory is where the masked images will be stored. The structure of the output directory will mirror that of the input directory, ensuring that each masked file is placed in the appropriate folder, keeping your data organized.
mask_file str The mask filename pattern used to identify mask files. File ending excluded.
The pattern can include wildcards:

* matches any sequence of characters (including an empty sequence).
? matches any single character.
[seq] matches any character in seq.
[!seq] matches any character not in seq.
mask_type MaskType Define the type of mask to apply.
value int The interpretation of the value depends on the chosen mask type:
Threshold: A floating-point value between 0 and 1 that determines the cutoff for masking.
Bitmask: A bitmask value where specific bits denote the mask criteria.
Value: A list of integers representing the classes to mask.
num_processes int To optimize and speed up the masking process, you can leverage parallel processing by defining the number of processes to use. For example, setting the number of processes to 5 allows for 5 images to be masked simultaneously. Default is 1.

Example¤

Python
from sipt.processing import mask
from sipt.processing.mask import MaskType

mask("./src", "./processed", "", MaskType.THRESHOLD, 0.1, 4)