diff --git a/app/otbSARPhaseFiltering.cxx b/app/otbSARPhaseFiltering.cxx index 29f3b0e81d1794f4e30acd72a40025ae152a6b7b..6fc825317ee777d3ed3677bba4b63e0cd3207647 100644 --- a/app/otbSARPhaseFiltering.cxx +++ b/app/otbSARPhaseFiltering.cxx @@ -34,6 +34,8 @@ #include "otbRealAndImaginaryImageToComplexImageFilter.h" #include "otbMultiToMonoChannelExtractROI.h" +#include "otbImageKeywordlist.h" + #include <iostream> #include <string> #include <fstream> @@ -102,6 +104,18 @@ namespace otb SetDefaultParameterInt("step", 16); MandatoryOff("step"); + AddParameter(ParameterType_Int, "mlran", "Averaging on distance for output interferogram"); + SetParameterDescription("mlran", "Averaging on distance for output interferogram."); + SetDefaultParameterInt("mlran", 1); + SetMinimumParameterIntValue("mlran", 1); + MandatoryOff("mlran"); + + AddParameter(ParameterType_Int, "mlazi", "Averaging on azimut for output interferogram"); + SetParameterDescription("mlazi", "Averaging on azimut for output interferogram."); + SetDefaultParameterInt("mlazi", 1); + SetMinimumParameterIntValue("mlazi", 1); + MandatoryOff("mlazi"); + AddParameter(ParameterType_Float, "alpha", "alpha parameter for Goldstein filter"); SetParameterDescription("alpha","alpha parameter for Goldstein filter."); SetDefaultParameterFloat("alpha", 0.7); @@ -109,8 +123,8 @@ namespace otb SetMaximumParameterFloatValue("alpha", 1); MandatoryOff("alpha"); - AddParameter(ParameterType_OutputImage, "out", "Output Compensated complex image (after filtering)"); - SetParameterDescription("out","Output Image : Compensated complex image after filtering."); + AddParameter(ParameterType_OutputImage, "out", "Output interferogram (after filtering)"); + SetParameterDescription("out","Output Image : Interferogram after filtering with 3 bands (amp, pha, coh)."); AddRAMParameter(); @@ -129,11 +143,14 @@ namespace otb float alpha = GetParameterFloat("alpha"); int step = GetParameterInt("step"); int sizeTiles = GetParameterInt("sizetiles"); - + int factor_azi = GetParameterInt("mlazi"); + int factor_ran = GetParameterInt("mlran"); + otbAppLogINFO(<<"Alpha for Goldstein filter : "<<alpha); otbAppLogINFO(<<"Step for window extraction (for each step pixel) : "<<step); otbAppLogINFO(<<"Size of tiles : "<<sizeTiles); - + otbAppLogINFO(<<"Averaging Factor on azimut for final interferogram :"<<factor_azi); + otbAppLogINFO(<<"Averaging Factor on range for final interferogram : "<<factor_ran); // Complex Ptr ComplexFloatImageType::Pointer inComplexPtr; @@ -145,11 +162,33 @@ namespace otb } else { + FloatVectorImageType::Pointer inInterfPtr = GetParameterFloatVectorImage("ininterf"); + + // Check ML factors (must be 1x1) thanks to the keyWordlist + otb::ImageKeywordlist KWL = inInterfPtr->GetImageKeywordlist(); + int mlran_interf = 1; + int mlazi_interf = 1; + if (KWL.HasKey("support_data.ml_ran")) + { + mlran_interf = std::atoi(KWL.GetMetadataByKey("support_data.ml_ran").c_str()); + } + if (KWL.HasKey("support_data.ml_azi")) + { + mlazi_interf = std::atoi(KWL.GetMetadataByKey("support_data.ml_azi").c_str()); + } + + if (mlran_interf != 1 || mlazi_interf != 1) + { + // Send an exception + itkExceptionMacro(<<"Input interferogram must be into master geometry (ML : 1x1)"); + } + + // Estimate ComplexCompensated image (VectorImage with : real, imag and mod as bands) CompensatedComplexFromInterferogramFilterType::Pointer compensatedComplexFromInterf = CompensatedComplexFromInterferogramFilterType::New(); m_Ref.push_back(compensatedComplexFromInterf.GetPointer()); - compensatedComplexFromInterf->SetInput(GetParameterFloatVectorImage("ininterf")); + compensatedComplexFromInterf->SetInput(inInterfPtr); // Transform VectorImage To Complex Type // Extract the first and second bands @@ -253,9 +292,9 @@ namespace otb GroupedByMLFilterType::Pointer filterGroupedBy = GroupedByMLFilterType::New(); m_Ref.push_back(filterGroupedBy.GetPointer()); filterGroupedBy->SetInput(filterPhase->GetOutput()); - filterGroupedBy->SetMLRan(3); - filterGroupedBy->SetMLAzi(3); - filterGroupedBy->SetGain(0.1); + filterGroupedBy->SetMLRan(factor_ran); + filterGroupedBy->SetMLAzi(factor_azi); + filterGroupedBy->SetGain(1); filterGroupedBy->SetMarginRan(1); filterGroupedBy->SetMarginAzi(1);