I need to rescale Sentinel2 data (both lvl 1C and 2A) to 8 bit, because of the requirements of a GRASS GIS module (i.histo.match
) that only works with values from 0:255. All the documentation of Sentinel2 1C and 2A data products say that the data are encoded at 12bit, but that is not up to date (also this other post pointed this out https://gis.stackexchange.com/a/234044/172030). In fact, if I run gdalinfo
on my L1C files, it says that it has 15 significant bits:
Image Structure Metadata:
COMPRESSION=JPEG2000
NBITS=15
while if I run it on my L2A files (created with Sen2Cor, not downloaded) it omits the "NBITS" field.
Image Structure Metadata:
COMPRESSION=JPEG2000
I don't know how to correctly perform the conversion: should I treat the data as formatted in 15 or 16 bits? I.e. DN / 2^15 * 2^8 or DN / 2^16 * 2^8? Is there any better way to perform this transformation?