ServiceNow / seasonal-contrast

seasonal-contrast is a ServiceNow Research project that was started at Element AI.
Apache License 2.0
162 stars 26 forks source link

4 or 8 pixel blocks in downloaded Sentinel imagery #7

Open MarcCoru opened 3 years ago

MarcCoru commented 3 years ago

hi Pau @prlz77 and Oscar @oscmansan,

Thanks for your work. We were downloading the data with seco_downloader.py but noticed a certain 4 or 8-pixel block structure in the images. Looking over the source code, I can't find a concrete reason. Could it be connected to the getInfo line https://github.com/ElementAI/seasonal-contrast/blob/5395c027922569f5c5b1785ad1ccddd839749c36/datasets/seco_downloader.py#L175 where (maybe) only an approximated representation of the images is returned?

Screenshot from 2021-10-21 11-46-25 image (1) image

josauder commented 3 years ago

I think I figured out the issue. The intensities of the bands are indivudally rescaled and reduced to 8-bits.

However, to capture the full depth of the S2-Sensors, the images must be saved to uint16 .tifs. I suspect the authors did not do this because rasterio doesn't seem to work with uint16 and compression='JPEG'. Changing the compression to 'None' seems to fix the problem.

The bands can then be concatenated to form the RGB image, and can be plotted in a way that they look as intended (after histogram normalization of all 3 bands at once):

image

wangyi111 commented 3 years ago

hi @MarcCoru , may i ask how did you sample these connected tiles? It seems the original code would randomly sample tiles around all the 1000 cities.