From 7d9f82f92d954e202121ed34eb75a67a1feaf939 Mon Sep 17 00:00:00 2001 From: Cedric <cedric.traizet@c-s.fr> Date: Mon, 14 Jan 2019 17:57:53 +0100 Subject: [PATCH] ENH: added parameters for radius --- .../app/otbLocalRxDetection.cxx | 37 +++++++++++++++---- .../include/otbLocalRxDetectorFilter.h | 20 ++++++---- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx b/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx index a78024938b..1bc0d09707 100644 --- a/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx @@ -73,11 +73,31 @@ private: SetParameterDescription("out","Output Rx score image"); MandatoryOn("out"); + AddParameter(ParameterType_Int, "irx", "X Internal radius"); + SetParameterDescription("irx", "Internal radius in pixel along the X axis"); + SetDefaultParameterInt("irx", 1); + + AddParameter(ParameterType_Int, "iry", "Y Internal radius"); + SetParameterDescription("iry","Internal radius in pixel along the Y axis"); + SetDefaultParameterInt("iry", 1); + + AddParameter(ParameterType_Int, "erx", "X External radius"); + SetParameterDescription("erx","External radius in pixel"); + SetDefaultParameterInt("erx", 3); + + AddParameter(ParameterType_Int, "ery", "Y External radius"); + SetParameterDescription("ery","External radius in pixel"); + SetDefaultParameterInt("ery", 3); + AddRAMParameter(); // Doc example parameter settings SetDocExampleParameterValue("in", "cupriteSubHsi.tif"); SetDocExampleParameterValue("out", "LocalRxScore.tif"); + SetDocExampleParameterValue("irx", "1"); + SetDocExampleParameterValue("iry", "1"); + SetDocExampleParameterValue("erx", "3"); + SetDocExampleParameterValue("ery", "3"); SetOfficialDocLink(); } @@ -97,10 +117,10 @@ private: auto detector = LocalRxDetectorFilterType::New(); detector->SetInput(inputImage); - - //TODO this should be app parameters - unsigned int externalRadius = 3; - unsigned int internalRadius = 1; + + // the radius are the same along x and y for the filter + unsigned int externalRadius = GetParameterInt("erx"); + unsigned int internalRadius = GetParameterInt("irx"); detector->SetInternalRadius(internalRadius); detector->SetExternalRadius(externalRadius); @@ -113,10 +133,13 @@ private: #else localRxDetectionFunctor<double> detectorFunctor; - detectorFunctor.SetInternalRadius(1); - auto localRxDetectionFunctorFilter = otb::NewFunctorFilter(detectorFunctor ,{{3,3}}); + detectorFunctor.SetInternalRadius(GetParameterInt("irx"), GetParameterInt("iry")); + + auto localRxDetectionFunctorFilter = otb::NewFunctorFilter + (detectorFunctor ,{{GetParameterInt("erx"),GetParameterInt("ery")}}); + localRxDetectionFunctorFilter->SetVariadicInputs(inputImage); - //localRxDetectionFunctorFilter->Update(); + SetParameterOutputImage("out", localRxDetectionFunctorFilter->GetOutput()); RegisterPipeline(); #endif diff --git a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h index 0971b8ab1c..ce174c8fcc 100644 --- a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h +++ b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h @@ -129,22 +129,28 @@ public: typedef typename CovarianceCalculatorType::MatrixType MatrixType; private: - int m_InternalRadius; + int m_InternalRadiusX; + int m_InternalRadiusY; public: - localRxDetectionFunctor():m_InternalRadius(1){}; + localRxDetectionFunctor() : m_InternalRadiusX(1), m_InternalRadiusY(1) {}; - void SetInternalRadius(int internalRadius) + void SetInternalRadius(int internalRadiusX, int internalRadiusY) { - m_InternalRadius = internalRadius; + m_InternalRadiusX = internalRadiusX; + m_InternalRadiusY = internalRadiusY; }; - int GetInternalRadius() + int GetInternalRadiusX() { - return m_InternalRadius; + return m_InternalRadiusX; }; + int GetInternalRadiusY() + { + return m_InternalRadiusY; + }; auto operator()(const itk::Neighborhood<itk::VariableLengthVector<T>> & in) const { @@ -164,7 +170,7 @@ public: for (int x = -static_cast<int>(externalRadius[0]); x <= static_cast<int>(externalRadius[0]); x++) { off[0] = x; - if ((abs(x) > m_InternalRadius) || (abs(y) > m_InternalRadius)) + if ((abs(x) > m_InternalRadiusX) || (abs(y) > m_InternalRadiusY)) {//std::cout << in[off] << std::endl; listSample->PushBack(in[off] ); } -- GitLab