diff --git a/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx b/Modules/Applications/AppHyperspectral/app/otbLocalRxDetection.cxx index a78024938b4cda3dc3122c5e15aca6b2b17bb944..1bc0d09707f2ebdad76af9245e1df5905bafe97d 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 0971b8ab1c0b2aa15b07b9567dd7e9a3725c6a5b..ce174c8fcc71245ba618c80ed8206baae18245aa 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] ); }