sentinel-hub/sentinel2-cloud-detector

Cloud Shadows

TabakoUA opened this issue · 10 comments

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

+1

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

Thanks man, I am looking into it

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..

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.

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

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?

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)