Apply masks on Satellite Images

GeoSense ✅
2 min readDec 23, 2022

When we use Satellite Imagery, they usually provide masks for clouds, water, etc. I will show you how to apply masks to remove water pixels from satellite images.

About Dataset

Context

A collection of water bodies images captured by the Sentinel-2 Satellite. Each image comes with a black and white mask where white represents water and black represents something else but water. The masks were generated by calculating the NWDI (Normalized Water Difference Index) which is frequently used to detect and measure vegetation in satellite images, but a greater threshold was used to detect water bodies.

Link: Satellite Images of Water Bodies

Example:

Original image
Mask for the above image

Desired output like this:

Water pixels were removed

Now, we start:

1. Load Libraries:

import numpy as np
import os
import matplotlib.pyplot as plt
from scipy import stats
import rasterio
from rasterio.plot import…

--

--

GeoSense ✅

🌏 Remote sensing | 🛰️ Geographic Information Systems (GIS) | ℹ️ https://www.tnmthai.com/medium