From d4e8eb679cf524dec550ec7aec3050065e62547d Mon Sep 17 00:00:00 2001 From: Impact <pascal.mouquet@ird.fr> Date: Thu, 25 Apr 2019 13:23:11 +0400 Subject: [PATCH] add b11 masking dilatation 6px --- sen2chain/cloud_mask.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sen2chain/cloud_mask.py b/sen2chain/cloud_mask.py index 3241839..7174a9b 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"]) -- GitLab