Enhance

Raster data often lacks the vibrant colors typically seen in natural imagery because it does not use the standard 8-bit resolution that computer monitors are designed to display. As a result, raw images often appear nearly black and white with little visible detail. To create natural-colored images, various image enhancement techniques must be applied. The SIPT library implements the algorithm used to create the Sentinel-2 L2A True Color Optimized images. The original description can be found [here]{https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2/l2a_optimized/}. The algorithm includes the following steps:

  • Highlight Compression
  • Gamma Correction
  • Saturation Boost
  • sRGB convertion

The sRGB convertion is intentionally not implemented. There is no need to change the color space.

Parameters¤

Name Type Description
input_dir str Input directory containing GeoTIFF files. Can contain subfolders.
output_dir str Output directory. If same as input then the original files are overwritten. Keeps subfolders.
alpha boolean Choose whether to add an alpha channel to the enhanced images for transparency or not.

Default: True
max_reflectance float Define the max reflectance used in highlight compression. Typical reflectance values fall between 0 and 1. Outliers are possible depending on the used image sensors.

Default: 3.0
min_reflectance float Define the min reflectance used in highlight compression. Typical reflectance values fall between 0 and 1. Outliers are possible depending on the used image sensors.

Default: 0.13
sat float Adjust the saturation. 1 is no change, < 1 reduces the saturation and > 1 increases the saturation.

Default: 1.6
gamma float The gamma correction factor that controls the non-linear mapping of intensity values (contrast).

Default: 1.8
gOff float An offset applied before and after the gamma adjustment, affecting the curve's shape and how the lower intensities are mapped.

Default: 0.01

Example¤

Python
from sipt.processing import enhance

enhance("./src", "./processed", True, 3.0, 0.13, 1.6, 1.8, 0.01)