diff --git a/app/otbSARCorrectionGrid.cxx b/app/otbSARCorrectionGrid.cxx index 75af1927780aa3844cde33abc052e32262b4aab6..b61dcefabb1a206bbc575785641e7824e0901fb3 100644 --- a/app/otbSARCorrectionGrid.cxx +++ b/app/otbSARCorrectionGrid.cxx @@ -215,6 +215,24 @@ void DoExecute() override std::cout << "diffMeanRange = " << diffMeanRange << std::endl; std::cout << "diffMeanAzimut = " << diffMeanAzimut << std::endl; + // Correction Filter to replace value into DEMGrid with no occurences (high gap and high threshold) + // by mean value + CorrectionGridFilterType::Pointer filterCorrectionGrid = CorrectionGridFilterType::New(); + m_Ref.push_back(filterCorrectionGrid.GetPointer()); + + // Configure CorrectionGrid Filter + filterCorrectionGrid->SetThreshold(1.5); + filterCorrectionGrid->SetGap(1000000); + filterCorrectionGrid->SetMeanRange(meanRangeDEM); + filterCorrectionGrid->SetMeanAzimut(meanAzimutDEM); + + // Define the main pipeline + filterCorrectionGrid->SetDEMGridInput(DEMGridPtr); + filterCorrectionGrid->SetCorGridInput(CorGridPtr); + + filterCorrectionGrid->UpdateOutputInformation(); + RegisterPipeline(); + // Offset for DEMGrid (Correction with the difference) // Instanciate all filters ListConcatenerFilterType::Pointer m_Concatener = @@ -227,7 +245,7 @@ void DoExecute() override ImageListType::New(); // Check number of components (at least two : range and azimut) - unsigned int nbComponents = DEMGridPtr->GetNumberOfComponentsPerPixel(); + unsigned int nbComponents = filterCorrectionGrid->GetOutput()->GetNumberOfComponentsPerPixel(); if (nbComponents < 2) { otbAppLogFATAL(<< "Input grid has to contain at least two components"); @@ -243,7 +261,7 @@ void DoExecute() override AddFilterType::New(); // Set the channel to extract - extractor->SetInput(DEMGridPtr); + extractor->SetInput(filterCorrectionGrid->GetOutput()); extractor->SetChannel(i+1); extractor->UpdateOutputInformation(); m_ExtractorList->PushBack(extractor); diff --git a/app/otbSARFineDeformationGrid.cxx b/app/otbSARFineDeformationGrid.cxx index 4686a1eeddb8b8fb26214860b51de9624d1b76ae..2dc7d8e619e90c9b35a095222d7b53b182ebea23 100644 --- a/app/otbSARFineDeformationGrid.cxx +++ b/app/otbSARFineDeformationGrid.cxx @@ -192,7 +192,7 @@ private: GetInternalApplication("CorGridApp")->SetParameterInt("mlazi", factor_azi); GetInternalApplication("CorGridApp")->SetParameterInt("gridsteprange", grid_step_ran); GetInternalApplication("CorGridApp")->SetParameterInt("gridstepazimut", grid_step_azi); - if (demGridToFavor) + //if (demGridToFavor) { GetInternalApplication("CorGridApp")->SetParameterInt("nooffset", 1); } diff --git a/python_src/diapOTB_S1IW.py b/python_src/diapOTB_S1IW.py index 7639b60c8075572d15fa70b26eadc6cef486d66b..62765eae0dd10b6daf96abf8b114f007d5446873 100644 --- a/python_src/diapOTB_S1IW.py +++ b/python_src/diapOTB_S1IW.py @@ -183,7 +183,26 @@ if __name__ == "__main__": if int(dictKWLMaster['header.version']) < 3 or int(dictKWLSlave['header.version']) < 3 : print ("Upgrade your geom file") quit() + + # Get information about DEM (spacing, size ..) + ReadDEMInfo = otb.Registry.CreateApplication("ReadImageInfo") + ReadDEMInfo.SetParameterString("in", dem) + ReadDEMInfo.SetParameterString("keywordlist", "true") + ReadDEMInfo.Execute() + + spacingXDEM = ReadDEMInfo.GetParameterFloat("spacingx") + estimatedGroundSpacingXDEM = ReadDEMInfo.GetParameterFloat("estimatedgroundspacingx") + spacingYDEM = ReadDEMInfo.GetParameterFloat("spacingy") + estimatedGroundSpacingYDEM = ReadDEMInfo.GetParameterFloat("estimatedgroundspacingy") + + # Choose advantage for correlation or projection according to DEM resolution + advantage = "projection" # By default projection + if estimatedGroundSpacingXDEM > 40. or estimatedGroundSpacingYDEM > 40. : + advantage = "correlation" # Correlation if resolution > 40 m + print("Resolution of the input DEM is inferior to 40 meters : A correlation will be used to correct all deformation grids") + + # Check the index of bursts minNbBurst = min([int(dictKWLMaster['support_data.geom.bursts.number']), int(dictKWLSlave['support_data.geom.bursts.number'])]) @@ -451,6 +470,7 @@ if __name__ == "__main__": appFineDeformationGrid.SetParameterInt("gridstepazimut", geoGrid_gridstep_azimut) appFineDeformationGrid.SetParameterFloat("threshold", geoGrid_threshold) appFineDeformationGrid.SetParameterFloat("gap", geoGrid_gap) + appFineDeformationGrid.SetParameterString("advantage", advantage) appFineDeformationGrid.SetParameterString("out", os.path.join(burst_dir, fine_grid)) appFineDeformationGrid.SetParameterString("ram", "4000") appFineDeformationGrid.ExecuteAndWriteOutput()