Foundations to Frontier
Tests
G. Computer Vision and Remote Sensing › G5 Remote Sensing and Earth Observation

Cloud masking and atmospheric correction

Optical satellites see the ground through the atmosphere and, about two thirds of the time, through clouds. Before pixels can be compared across dates or sensors they need two corrections. Atmospheric correction turns top-of-atmosphere (TOA) reflectance into surface reflectance by removing scattered path light and undoing lost transmittance (6S, LaSRC, Sen2Cor, MAJA). Cloud and shadow masking removes pixels that show cloud tops instead of land (Fmask, s2cloudless, Cloud Score+, deep networks trained on CloudSEN12). This page covers the radiometric chain from digital numbers to surface reflectance, aerosol retrieval, the spectral tests behind rule-based cloud masks, shadow geometry, and the standard Landsat and Sentinel-2 products. In the exercises you convert radiance and stored integers to reflectance, write Fmask-style tests and project cloud shadows. You then build a 20000-pixel scene with haze (aerosol optical depth 0.3), thick cloud, thin cirrus, snow and bright sand. A blue-brightness threshold flagged all snow and 92% of bright sand as cloud. Fmask-style rules reached precision 0.974 but caught only 58% of thin cirrus, and adding the 1.375 µm cirrus band raised this to 96%. Without correction, vegetation NDVI was biased by −0.137. Dark-object subtraction overshot to +0.051, a dark-target aerosol retrieval cut the bias to +0.022, and a wrongly assumed aerosol depth of 0.1 left −0.063.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Seeing the ground through air and clouds

A satellite looking down sees the ground through a layer of air and haze, as if through a slightly dirty window. The air adds a bluish glow of scattered sunlight and dims the light coming back from the surface, so dark forests look brighter and less green than they are. Clouds are worse: where a cloud sits, the satellite sees only the cloud top, and next to it lies the cloud’s shadow. Before a picture can be used for science, these pixels have to be found and removed, and the haze has to be subtracted. The demo shows how haze changes what the satellite measures in each colour band.

Earth-observation lab: correction, change, classes, foundation models
bluegreenredNIRSWIR1SWIR2
Green: vegetation surface reflectance; red: what the satellite sees at AOT 0.3. Scattering adds path reflectance in the blue and red, so NDVI drops from 0.772 to 0.637. Correction must remove the added light and undo the lost transmittance.
Why engineers care

Crop, flood and deforestation monitoring compare images taken weeks or years apart. Leftover haze or a missed thin cloud looks exactly like a real change on the ground, so correction and masking come first in every operational pipeline.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Haze mostly makes a dark forest look…
  2. 2. A cloud mask removes…
  3. 3. Surface reflectance is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

From digital numbers to surface reflectance

  • Radiometric chain: digital number → at-sensor radiance (gain and offset) → TOA reflectance ρ = π L d² / (E_sun cos θ_s) → surface (bottom-of-atmosphere, BOA) reflectance after atmospheric correction.
  • Stored products: Landsat Collection 2 Level-2 surface reflectance is stored as integers with reflectance = 2.75·10⁻⁵ · DN − 0.2. Sentinel-2 L1C (TOA) and L2A (BOA) store reflectance × 10000. Since processing baseline 04.00 (January 2022) an offset of −1000 is added, so reflectance = (DN − 1000) / 10000. Forgetting the offset biases every pixel by 0.1.
  • What the atmosphere does: molecules scatter strongly at short wavelengths (Rayleigh, about λ⁻⁴). Aerosols scatter with an Ångström power law. Together they add path reflectance and reduce transmittance. Water vapour and ozone absorb in specific bands, and the 1.375 µm band is almost opaque to the surface, which makes it a cirrus detector.
  • Correction methods: dark-object subtraction (Chavez 1988) subtracts a per-band haze value. Physics codes such as 6S (Vermote et al. 1997), MODTRAN/FLAASH and libRadtran invert a radiative-transfer model with aerosol and water vapour estimated from the image. Operational processors: LEDAPS (Landsat 4–7) and LaSRC (Landsat 8–9) for USGS Collection 2, Sen2Cor (ESA Sentinel-2 L2A, with a scene classification layer), MAJA (CNES, multi-temporal), FORCE, and ACOLITE for water.
  • Aerosol retrieval: the dark-target idea (Kaufman et al. 1997) uses the fact that over dense vegetation surface red ≈ 0.5 × and blue ≈ 0.25 × the 2.1 µm reflectance, which aerosols barely affect.
  • Clouds: rule-based Fmask (Zhu and Woodcock 2012; Fmask 4.0, Qiu et al. 2019) and its C port CFMask behind the Landsat QA_PIXEL band; Sen2Cor’s SCL classes; s2cloudless (Sentinel Hub, a gradient-boosted per-pixel classifier); Google’s Cloud Score+ (2023) usability scores; and CNNs trained on CloudSEN12 (Aybar et al. 2022).
  • Harmonised products: NASA’s HLS combines Landsat 8–9 and Sentinel-2 at 30 m with common atmospheric correction, Fmask, BRDF normalisation and band adjustment.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Rayleigh scattering is strongest in the…
  2. 2. Sentinel-2 L2A reflectance since baseline 04.00 is…
  3. 3. The 1.375 µm band is useful because…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Correcting and masking in practice

Exercise 1.

  • TOA reflectance from radiance; Landsat Collection 2 and Sentinel-2 L2A scaling.
  • Dark-object subtraction.
  • Fmask-style potential-cloud tests.
  • Cloud-shadow offset from cloud height and sun angles.

Practice.

  • Start from Level-2 surface reflectance products (Landsat Collection 2 L2, Sentinel-2 L2A, HLS) unless you have a reason not to; check the scale and offset in the metadata.
  • Combine the provider’s mask (QA_PIXEL bits, SCL classes) with a modern score (s2cloudless probability, Cloud Score+) and dilate cloud and shadow masks by a few pixels.
  • Inspect masks over snow, bright desert, urban roofs and coasts: these are where rule sets fail.
  • For time series, build composites (median or best-pixel) from many masked dates rather than hunting for one clear image.
  • Never mix TOA and BOA reflectance, or products with different processing baselines, in one model without harmonising them.
import ee
ee.Initialize()
s2 = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").filterDate("2025-05-01", "2025-09-30")
cs = ee.ImageCollection("GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED")
def mask(img):
    return img.updateMask(img.select("cs").gte(0.6)).divide(10000)   # harmonised collection: offset already removed
composite = s2.linkCollection(cs, ["cs"]).map(mask).median()
ndvi = composite.normalizedDifference(["B8", "B4"])
🐍 Exercise 1: reflectance, haze and cloud tests
Convert radiance and stored integers to reflectance, subtract dark-object haze, write Fmask-style cloud tests and project cloud shadows.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Provider cloud masks are weakest over…
  2. 2. Cloud masks are usually dilated because…
  3. 3. For a cloud-free view of a region, use…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

A simple atmosphere. For a Lambertian surface of reflectance ρ, TOA reflectance is ρ_TOA = ρ_path + T ρ / (1 − S ρ), with path reflectance ρ_path, two-way transmittance T and spherical albedo S. Inversion is exact when the three are known: y = ρ_TOA − ρ_path, ρ = y / (T + S y). All of them depend on the aerosol optical depth τ_a(λ) = τ_550 (λ/0.55)^(−α) and on the Rayleigh depth, which falls as about λ⁻⁴.

Why NDVI drops without correction. Path reflectance is added to every band but matters most where the surface is dark, as in the red band of vegetation. NIR is bright and barely changed. Red rises relative to NIR, so NDVI falls. Dark-object subtraction removes an additive haze term but ignores the multiplicative loss T. In the exercise it also subtracted a red haze estimated from the darkest pixels, which were brighter than its 1% assumption, so NDVI overshot.

Cloud tests. Clouds are bright, spectrally flat (white), cold and bright in SWIR. Snow is bright and white in the visible but dark at 1.6 µm, so NDSI = (green − SWIR1)/(green + SWIR1) separates them. Bright sand and soil are bright but redder than they are blue, so the whiteness test and the haze-optimised transform (HOT = blue − 0.5 red, Zhang et al. 2002) reject them. Thin cirrus adds only a few per cent of reflectance and passes most visible tests. At 1.375 µm, water vapour absorbs the surface signal, so only high clouds remain visible.

Shadow geometry. A cloud at height h casts its shadow h tan θ_s away from the sun along the solar azimuth. Fmask searches heights along this line for the position where the projected cloud best matches dark, potentially shadowed pixels.

Revisit and clear views. If each look is cloudy with probability p independently, n looks give at least one clear view with probability 1 − pⁿ. Correlation between dates (persistent cloud seasons) makes the real number lower.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Inversion of the simple model is ρ = …
  2. 2. Snow and cloud are separated by…
  3. 3. Thin cirrus is hard because…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Which cloud tests and which atmospheric corrections actually matter for NDVI?

History.

  • P. S. Chavez, “An improved dark-object subtraction technique for atmospheric scattering correction of multispectral data” (1988).
  • Y. J. Kaufman et al., “The MODIS 2.1-µm channel: correlation with visible reflectance for use in remote sensing of aerosol” (1997).
  • E. F. Vermote, D. Tanré, J. L. Deuzé, M. Herman and J.-J. Morcrette, “Second simulation of the satellite signal in the solar spectrum, 6S” (1997).
  • Z. Zhu and C. E. Woodcock, “Object-based cloud and cloud shadow detection in Landsat imagery” (2012); S. Qiu, Z. Zhu and B. He, “Fmask 4.0” (2019).

Exercise 2. 20000 pixels of a Landsat-like sensor (blue, green, red, NIR, SWIR1, SWIR2, plus a 1.375 µm cirrus band and a thermal brightness temperature).

  • Surfaces: vegetation, soil, water, bright sand/urban and snow. Vegetation red/SWIR2 = 0.56, slightly off the 0.5 assumed by the dark-target method.
  • Atmosphere: a toy single-scattering model (Rayleigh plus aerosol, AOT 0.3 at 550 nm), plus sensor noise.
  • Clouds: 20% thick cloud and 10% thin cirrus (adding 1–6% reflectance). Cloud fraction 0.307.
  • Masks: blue TOA > 0.2; Fmask-style potential-cloud rules (basic, whiteness, HOT and NIR/SWIR1 tests); rules plus cirrus band > 0.01.
  • Corrections: none, dark-object subtraction, dark-target AOT retrieval, known AOT, and a default AOT of 0.1.
cloud mask precision thin cirrus caught snow flagged sand flagged NDVI bias of kept vegetation
blue > 0.2 0.573 0.236 1.0 0.921 −0.0173
Fmask-style rules 0.974 0.578 0.001 0.058 −0.0028
rules + cirrus band 0.977 0.962 0.001 0.058 −0.0001
correction RMSE blue RMSE red vegetation NDVI bias
none (TOA) 0.077 0.0323 −0.1373
dark-object subtraction 0.075 0.0436 +0.0512
assumed AOT 0.1 0.0251 0.0143 −0.0633
dark-target AOT retrieval (0.36) 0.0089 0.0051 +0.0219
known AOT 0.3 0.0028 0.0023 +0.0002
  • Brightness alone fails: every snow pixel and 92% of sand were called cloud. The SWIR, whiteness and HOT tests removed almost all of these false alarms; all methods caught all thick clouds.
  • The cirrus band matters: the rules missed 42% of thin cirrus, which biased the NDVI of the vegetation kept. The 1.375 µm band fixed this (0.578 → 0.962 on seed 0, 0.544 → 0.952 and 0.543 → 0.949 on seeds 1 and 2).
  • Dark-object subtraction did not help: it barely changed the blue error, made red worse and flipped the NDVI bias to +0.05 on every seed (+0.0505 and +0.0473 on seeds 1 and 2). This is a negative result for the simplest method.
  • Retrieving the aerosol beats assuming it: the dark-target estimate (0.36 against a true 0.30, on all three seeds) cut the NDVI bias from −0.137 to +0.022. Its error comes from the red/SWIR2 ratio assumption, not from noise.
  • Caveat: a toy atmosphere with fixed geometry, independent pixels (no spatial context or shadows) and Fmask’s first pass only. Real Fmask adds probabilities, scene-based thresholds and shadow matching.
🐍 Exercise 2 (research): which cloud tests and which atmospheric corrections actually matter for NDVI?
Simulate a hazy, partly cloudy scene; compare brightness, Fmask-style and cirrus-band cloud masks, and none, dark-object, dark-target and known-AOT atmospheric corrections.

Cloud masking and atmospheric correction in AI, robotics and aerospace

  • Analysis-ready data: USGS Collection 2 Level-2, Sentinel-2 L2A and NASA HLS deliver surface reflectance with QA masks. CEOS Analysis Ready Data specifications define what “ready” means.
  • Training data hygiene: foundation models and land-cover classifiers trained on uncorrected or poorly masked data learn haze and cloud edges as features. Most EO pre-training pipelines filter scenes by cloud score first.
  • On-board processing: missions such as ESA’s Φsat-1 ran a cloud-detection network on board to discard cloudy images before downlink, saving bandwidth.

References

  1. P. S. Chavez (1988). “An improved dark-object subtraction technique for atmospheric scattering correction of multispectral data.” Remote Sensing of Environment.
  2. E. F. Vermote et al. (1997). “Second simulation of the satellite signal in the solar spectrum, 6S: an overview.” IEEE Transactions on Geoscience and Remote Sensing.
  3. Y. J. Kaufman et al. (1997). “The MODIS 2.1-µm channel: correlation with visible reflectance for use in remote sensing of aerosol.” IEEE TGRS.
  4. Z. Zhu and C. E. Woodcock (2012). “Object-based cloud and cloud shadow detection in Landsat imagery.” Remote Sensing of Environment.
  5. S. Qiu, Z. Zhu and B. He (2019). “Fmask 4.0: improved cloud and cloud shadow detection in Landsats 4–8 and Sentinel-2 imagery.” Remote Sensing of Environment.
  6. M. Main-Knorn et al. (2017). “Sen2Cor for Sentinel-2.” Proc. SPIE.
  7. C. Aybar et al. (2022). “CloudSEN12, a global dataset for semantic understanding of cloud and cloud shadow in Sentinel-2.” Scientific Data.
  8. V. J. Pasquarella et al. (2023). “Comprehensive quality assessment of optical satellite imagery using weakly supervised video learning” (Cloud Score+). CVPR Workshops.