diff --git a/Modules/Applications/AppFiltering/app/otbDespeckle.cxx b/Modules/Applications/AppFiltering/app/otbDespeckle.cxx index a580f1243bf5fb3309a2e529c1d0e524eaf2382b..bdd6b49716617018bb03971f16d12fe04a7e185e 100644 --- a/Modules/Applications/AppFiltering/app/otbDespeckle.cxx +++ b/Modules/Applications/AppFiltering/app/otbDespeckle.cxx @@ -20,6 +20,8 @@ #include "otbFrostImageFilter.h" #include "otbLeeImageFilter.h" +#include "otbGammaMAPImageFilter.h" +#include "otbKuanImageFilter.h" #include "otbMultiToMonoChannelExtractROI.h" namespace otb @@ -38,8 +40,10 @@ public: typedef itk::ImageToImageFilter<FloatImageType, FloatImageType> SpeckleFilterType; - typedef LeeImageFilter<FloatImageType, FloatImageType> LeeFilterType; - typedef FrostImageFilter<FloatImageType, FloatImageType> FrostFilterType; + typedef LeeImageFilter<FloatImageType, FloatImageType> LeeFilterType; + typedef FrostImageFilter<FloatImageType, FloatImageType> FrostFilterType; + typedef GammaMAPImageFilter<FloatImageType, FloatImageType> GammaMAPFilterType; + typedef KuanImageFilter<FloatImageType, FloatImageType> KuanFilterType; /** Standard macro */ itkNewMacro(Self); @@ -54,7 +58,7 @@ private: // Documentation SetDocName("Despeckle"); - SetDocLongDescription("This application reduce speckle noise. Two methods are available: Lee and Frost."); + SetDocLongDescription("This application reduce speckle noise. Four methods are available: Lee, Frost, GammaMAP and Kuan."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); SetDocSeeAlso(" "); @@ -74,6 +78,10 @@ private: SetParameterDescription("filter.lee","Lee filter"); AddChoice("filter.frost","Frost"); SetParameterDescription("filter.frost","Frost filter"); + AddChoice("filter.gammamap","GammaMap"); + SetParameterDescription("filter.gammamap","GammaMap filter"); + AddChoice("filter.kuan","Kuan"); + SetParameterDescription("filter.kuan","Kuan filter"); AddParameter(ParameterType_Int,"filter.lee.rad","Radius"); SetParameterDescription("filter.lee.rad","Radius for lee filter"); @@ -86,12 +94,26 @@ private: AddParameter(ParameterType_Float,"filter.frost.deramp","deramp"); SetParameterDescription("filter.frost.deramp","Decrease factor declaration"); + + AddParameter(ParameterType_Int,"filter.gammamap.rad","Radius"); + SetParameterDescription("filter.gammamap.rad","Radius for GammaMAP filter"); + + AddParameter(ParameterType_Float,"filter.gammamap.nblooks","nb looks"); + SetParameterDescription("filter.gammamap.nblooks","Nb looks for GammaMAP filter"); + + AddParameter(ParameterType_Int,"filter.kuan.rad","Radius"); + SetParameterDescription("filter.kuan.rad","Radius for Kuan filter"); + + AddParameter(ParameterType_Float,"filter.kuan.nblooks","nb looks"); + SetParameterDescription("filter.kuan.nblooks","Nb looks for Kuan filter"); // Default values SetDefaultParameterInt("filter.lee.rad", 1); SetDefaultParameterFloat("filter.lee.nblooks", 1.); SetDefaultParameterInt("filter.frost.rad", 1); SetDefaultParameterFloat("filter.frost.deramp", 0.1); + SetDefaultParameterInt("filter.gammamap.rad", 1); + SetDefaultParameterFloat("filter.gammamap.nblooks", 1.); // Doc example parameter settings @@ -158,6 +180,40 @@ private: m_SpeckleFilter = filter; break; } + case 2: + { + GammaMAPFilterType::Pointer filter = GammaMAPFilterType::New(); + m_Ref.push_back(filter.GetPointer()); + + filter->SetInput(inImage); + + GammaMAPFilterType::SizeType lradius; + lradius.Fill(GetParameterInt("filter.gammamap.rad")); + + filter->SetRadius(lradius); + filter->SetNbLooks(GetParameterFloat("filter.gammamap.nblooks")); + + otbAppLogINFO( << "GammaMAP filter" ); + m_SpeckleFilter = filter; + break; + } + case 3: + { + KuanFilterType::Pointer filter = KuanFilterType::New(); + m_Ref.push_back(filter.GetPointer()); + + filter->SetInput(inImage); + + KuanFilterType::SizeType lradius; + lradius.Fill(GetParameterInt("filter.kuan.rad")); + + filter->SetRadius(lradius); + filter->SetNbLooks(GetParameterFloat("filter.kuan.nblooks")); + + otbAppLogINFO( << "Kuan filter" ); + m_SpeckleFilter = filter; + break; + } default: { otbAppLogFATAL(<<"non defined speckle reduction filter "<<GetParameterInt("filter")<<std::endl); diff --git a/Modules/Applications/AppFiltering/test/CMakeLists.txt b/Modules/Applications/AppFiltering/test/CMakeLists.txt index 46a40c49880a6cc7c6fbfa6ac92963dfd3e02a44..d497c9bf8e1b6d51f5668b4ce2ee4be134d91078 100644 --- a/Modules/Applications/AppFiltering/test/CMakeLists.txt +++ b/Modules/Applications/AppFiltering/test/CMakeLists.txt @@ -30,4 +30,48 @@ otb_test_application(NAME apTvUtSmoothingTest_OutXML VALID --compare-image ${NOTOL} ${BASELINE}/apTvUtSmoothingTest.tif ${TEMP}/apTvUtSmoothingTest_OutXML.tif) + + +otb_test_application(NAME apTvDespeckleLee + APP Despeckle + OPTIONS -in ${INPUTDATA}/GomaAvant.tif + -out ${TEMP}/bfFiltreLee_05_05_12_app.tif + -filter lee + -filter.lee.rad 5 + -filter.lee.nblooks 12 + VALID --compare-image ${EPSILON_7} + ${BASELINE}/bfFiltreLee_05_05_12.tif + ${TEMP}/bfFiltreLee_05_05_12_app.tif) + +otb_test_application(NAME apTvDespeckleFrost + APP Despeckle + OPTIONS -in ${INPUTDATA}/GomaAvant.tif + -out ${TEMP}/bfFiltreFrost_05_05_12_app.tif + -filter frost + -filter.frost.rad 5 + -filter.frost.deramp 0.1 + VALID --compare-image ${EPSILON_7} + ${BASELINE}/bfFiltreLee_05_05_12.tif + ${TEMP}/bfFiltreLee_05_05_12_app.tif) +otb_test_application(NAME apTvDespeckleGammaMAP + APP Despeckle + OPTIONS -in ${INPUTDATA}/GomaAvant.tif + -out ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif + -filter gammamap + -filter.gammamap.rad 5 + -filter.gammamap.nblooks 12 + VALID --compare-image ${EPSILON_7} + ${BASELINE}/bfFiltreGammaMAP_05_05_12.tif + ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif) + +otb_test_application(NAME apTvDespeckleKuan + APP Despeckle + OPTIONS -in ${INPUTDATA}/GomaAvant.tif + -out ${TEMP}/bfFiltreKuan_05_05_12_app.tif + -filter kuan + -filter.kuan.rad 5 + -filter.kuan.nblooks 12 + VALID --compare-image ${EPSILON_7} + ${BASELINE}/bfFiltreKuan_05_05_12.tif + ${TEMP}/bfFiltreKuan_05_05_12_app.tif)