sentinel-hub / sentinel2-cloud-detector

Sentinel Hub Cloud Detector for Sentinel-2 images in Python
Creative Commons Attribution Share Alike 4.0 International
437 stars 94 forks source link

Cloud Shadows #15

Open TabakoUA opened 5 years ago

TabakoUA commented 5 years ago

First of all, thank you all guys (and ladies). You've done a great job with this cloud detection approach. Did You make any tries for cloud shadows detection? Or probably You can advise some ready2use methods? Thanks in advance!

0xmtn commented 3 years ago

+1

azupanc commented 3 years ago

This custom script in Sentinel Hub's custom script repository combines s2cloudless cloud mask with a model that was trained to identify clouds, cloud shadow, haze, snow and water. There's definitely room for improvement, but perhaps it is a good starting point.

0xmtn commented 3 years ago

Thanks man, I am looking into it

karinakort commented 1 year ago

Hello! Could anyone please help me to understand, how to mask shadows.

I tried to use 10 bands like in comments here . tried to use all 13 bands, different thresholds..but I cant't get shadows mask =(( The advice about the custom script application did'tt help to solve my problem. The shadows after masking are always the same color as open water..

azupanc commented 1 year ago

The linked custom script identifies open water as observation outliers. If your use case focuses to water, then this is obviously an issue. If not, then such false positives are not really an issue. We successfully use this model to filter out clouds, cloud shadows and haze in land monitoring applications.

karinakort commented 1 year ago

Thank you for your answer! My case focuses on areas of open water surrounded by sea ice (polynyas) . The clouds have been successfully masked , but there are problems with shadows (for example, in one part of the image the cloud shadows are masked, in the other - they are not). In other words, the algorithm identifies shadows, but not always..

пн, 16 янв. 2023 г. в 11:07, Anze Zupanc @.***>:

The linked custom script identifies open water as observation outliers. If your use case focuses to water, then this is obviously an issue. If not, then such false positives are not really an issue. We successfully use this model to filter out clouds, cloud shadows and haze in land monitoring applications.

— Reply to this email directly, view it on GitHub https://github.com/sentinel-hub/sentinel2-cloud-detector/issues/15#issuecomment-1383633259, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4FVZECAI36RTS65QO4J74DWST6VTANCNFSM4G7QCUVA . You are receiving this because you commented.Message ID: @.***>

azupanc commented 1 year ago

The model that was converted to linked custom script doesn't seem to generalise to area of your interest. This is not surprising since the datasets that was trained one is from mid latitudes and focused to agricultural areas.

Have you tried using sen2cor Scene Classification Layer? Example

karinakort commented 1 year ago

Yes ,I’ve . I have been used fragment of script like here : https://github.com/sentinel-hub/sentinel2-cloud-detector/issues/1 (10 bands and 13 bands )

For Arctic region Fmask is better, I think.

My results:

Пн, 16 янв. 2023 г. в 14:05, Anze Zupanc @.***>:

The model that was converted to linked custom script doesn't seem to generalise to area of your interest. This is not surprising since the datasets that was trained one is from mid latitudes and focused to agricultural areas.

Have you tried using sen2cor Scene Classification Layer? Example https://apps.sentinel-hub.com/eo-browser/?zoom=9&lat=60.37993&lng=31.138&themeId=DEFAULT-THEME&visualizationUrl=https%3A%2F%2Fservices.sentinel-hub.com%2Fogc%2Fwms%2Fbd86bcc0-f318-402b-a145-015f85b9427e&datasetId=S2L2A&fromTime=2023-01-13T00%3A00%3A00.000Z&toTime=2023-01-13T23%3A59%3A59.999Z&layerId=SCENE-CLASSIFICATION&demSource3D=%22MAPZEN%22

— Reply to this email directly, view it on GitHub https://github.com/sentinel-hub/sentinel2-cloud-detector/issues/15#issuecomment-1383874121, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4FVZEFJKJXNXSCYKXPNXMDWSUTPLANCNFSM4G7QCUVA . You are receiving this because you commented.Message ID: @.***>

MateusVidotti commented 1 year ago

Hello. Has anyone tested this Google Earth Engine(GEE) script for cloud and shodow cloud mask?. I tested and got good result for classification of cloud shadows. I'm trying to reproduce this cloud mask without using GEE. For this I need to find a way to reproduce what the GEE function directionalDistanceTransform does. "For each zero-valued pixel in the source, get the distance to the nearest non-zero pixels in the given direction". Anyone have an idea?

eoasker commented 11 months ago

Hello. Has anyone tested this Google Earth Engine(GEE) script for cloud and shodow cloud mask?. I tested and got good result for classification of cloud shadows. I'm trying to reproduce this cloud mask without using GEE. For this I need to find a way to reproduce what the GEE function directionalDistanceTransform does. "For each zero-valued pixel in the source, get the distance to the nearest non-zero pixels in the given direction". Anyone have an idea?

Hi there. I'm also trying to reproduce the cloud mask without GEE. I was thinking of something like this but I'm pretty sure I have something wrong there since the cloud shadow I get is wrong. Any thoughts?

    # Convert azimuth to radians
    cos_angle = np.cos(np.radians(azimuth))

    # Calculate directional distance transform
    directional_distance = cv2.distanceTransform(binary_mask.astype(np.uint8), cv2.DIST_L2, 5)

    # Apply the direction angle to get directional distance
    directional_distance *= cos_angle

    result = (directional_distance <= DISTANCE).astype(np.uint8)