I have to replace area with clouds from another image without clouds. So I have a problem when I remove clouds from my mask I have borders of clouds. I use Sentinel-2 SLC image. For begin I open my mask of scene classification(SLC) in 'jp2' formats. Then I resize my image to format my composites(10980x10980). I use ReadAsArray for both files. Then, where mask have labels with clouds and shadows I set 0 and works with arrays:

raster_composite1[:, mask_slc1 == 0] = raster_composite2[:, mask_slc1 == 0]#i have 4 bands 

Input image:

enter image description here

In output I have image:

enter image description here

So, how can I remove those white borders ?

  • You could expand the areas covered with clouds and then remove those areas. But you will still have to cope with shadows.
    – Alešinar
    Sep 12, 2019 at 13:40
  • @Alešinar Could you give me some advice how can i do that ?
    – kGummyBear
    Sep 12, 2019 at 14:18

1 Answer 1


The cloud mask provided by Sentinel2 L2A, from Sen2cor software, is not dilated. You could try to dilate it using scipy.ndimage.dilate in python. That would increase the surface of detected clouds by a given buffer (for instance 200m).

The trouble is that the L2A scene classification from Sen2cor also has plenty of false clouds on towns and buildings, which, once dilated could make large regions disappear.

Other cloud mask solutions exist that do not have this issue:

Baetens, L.; Desjardins, C.; Hagolle, O. Validation of Copernicus Sentinel-2 Cloud Masks Obtained from MAJA, Sen2Cor, and FMask Processors Using Reference Cloud Masks Generated with a Supervised Active Learning Procedure. Remote Sens. 2019, 11, 433.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.