I have downloaded 13 Sentinel-2 L1C bands individually which are in jp2 format.
I am trying to create a cloud mask and cloud probability map using the Sentinel-2 S2PixelCloudDetector algorithm.
All the bands are resampled to the 10m resolution and stacked to form the 3D array required as the input to the algorithm:
bands_array = np.dstack((B1,B2,B4,B5,B8,B8A,B9,B10,B11,B12))
bands_array.shape
(10980, 10980, 10)
The cloud detector is then ran as follows for the 10 band array:
cloud_detector = S2PixelCloudDetector(threshold=0.6, average_over=4, dilation_size=2, all_bands=False)
cloud_mask = cloud_detector.get_cloud_masks(bands_array[np.newaxis, ...])
However, when viewing the output it looks like the figure below. The white area is all land and the black area is actually just a no data area outside of the swath coverage. I have tried different cloud thresholds but keep getting this result which classifies all land as cloud. The actual image has been inspected and there is sparse cloud across the area but not full cloud cover. Any ideas why this could be happening?
I have tried different parameters as the inputs to the cloud detector and checking the band order is correct.
Not sure if you have found the problem already, but I believe you need to divide the bands by 10000 since the classifier expects the reflectances to be between 0 and 1. So just do B/10000.0 to every band you pass to the detector.