diff --git a/sen2chain/cloud_mask.py b/sen2chain/cloud_mask.py index 3241839ec51b159e2798fa39fbfefab4e5bcf21b..7174a9b84168ed0f82d2877ca7f6bb9c1e3b5b14 100755 --- a/sen2chain/cloud_mask.py +++ b/sen2chain/cloud_mask.py @@ -370,21 +370,28 @@ def create_cloud_mask_b11( BinaryMorphologicalOperation.ExecuteAndWriteOutput() # Masquage du masque - logger.info("00") BandMath = otbApplication.Registry.CreateApplication("BandMath") - logger.info("01") BandMath.SetParameterStringList("il", [str(cloud_mask),str(out_dilate)]) - logger.info("02") BandMath.SetParameterString("out", out_mask) BandMath.SetParameterOutputImagePixelType("out", 0) - logger.info("03") BandMath.SetParameterString("exp", "(im1b1 == 1) * (im2b1 == 0)") - logger.info("04") BandMath.ExecuteAndWriteOutput() - logger.info("05") + + # Dilatation + BinaryMorphologicalOperation = otbApplication.Registry.CreateApplication("BinaryMorphologicalOperation") + BinaryMorphologicalOperation.SetParameterString("in", out_mask) + BinaryMorphologicalOperation.SetParameterString("out", out_dilate) + BinaryMorphologicalOperation.SetParameterOutputImagePixelType("out", 0) + BinaryMorphologicalOperation.SetParameterInt("channel", 1) + BinaryMorphologicalOperation.SetParameterInt("structype.ball.xradius", dilatation+1) + BinaryMorphologicalOperation.SetParameterInt("structype.ball.yradius", dilatation+1) + BinaryMorphologicalOperation.SetParameterFloat("filter.dilate.foreval", 1) + BinaryMorphologicalOperation.SetParameterString("filter", "dilate") + BinaryMorphologicalOperation.ExecuteAndWriteOutput() + # Save to JP2000 - src_ds = gdal.Open(out_mask) + src_ds = gdal.Open(out_dilate) driver = gdal.GetDriverByName("JP2OpenJPEG") dst_ds = driver.CreateCopy(str(out_path), src_ds, options=["CODEC=JP2", "QUALITY=100", "REVERSIBLE=YES", "YCBCR420=NO"])