diff --git a/Documentation/Cookbook/rst/recipes/featextract.rst b/Documentation/Cookbook/rst/recipes/featextract.rst index 64eea1135b99651510c300a8a0adbbaaed4b05f8..46ce3ebf89e4b021a209241955d6a81049c7f733 100644 --- a/Documentation/Cookbook/rst/recipes/featextract.rst +++ b/Documentation/Cookbook/rst/recipes/featextract.rst @@ -216,20 +216,20 @@ parameters: -``-structype`` the choice of the structuring element type (ball/cross) (default value is ball) --``(-structype.ball.xradius)`` the ball structuring element X Radius - (only if structype==ball) (default value is 5 pixels) +-``(-xradius)`` the ball structuring element X Radius + (default value is 5 pixels) --``(-structype.ball.yradius)`` the ball structuring element Y Radius - (only if structype==ball) (default value is 5 pixels) +-``(-yradius)`` the ball structuring element Y Radius + (default value is 5 pixels) -``-filter`` the choice of the morphological operation (dilate/erode/opening/closing) (default value is dilate) --``(-filter.dilate.foreval)`` the foreground value for the dilation - (idem for filter.erode/opening/closing) (default value is 1) +-``(-foreval)`` the foreground value + (Used for dilate/erode/opening/closing morphological operations) (default value is 1) --``(-filter.dilate.backval)`` the background value for the dilation - (idem for filter.erode/opening/closing) (default value is 0) +-``(-backval)`` the background value + (Used for dilate/erode/opening morphological operations) (default value is 0) -``-out`` the output filtered image @@ -243,8 +243,8 @@ The application can be used as follows: -structype.ball.xradius 10 -structype.ball.yradius 5 -filter opening - -filter.opening.foreval 1.0 - -filter.opening.backval 0.0 + -foreval 1.0 + -backval 0.0 -out OutputImage Gray scale morphological operations diff --git a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx index 664bab6e4bd621226f5525cab2a823e395ee2dbe..2dc489f4bd85e06d930baf3b14bcd34f035236ae 100644 --- a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx +++ b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx @@ -96,8 +96,14 @@ private: SetDefaultParameterInt("channel", 1); SetMinimumParameterIntValue("channel", 1); + // Structuring element type AddParameter(ParameterType_Choice, "structype", "Type of structuring element"); SetParameterDescription("structype", "Choice of the structuring element type"); + AddChoice("structype.box", "Box"); + AddChoice("structype.ball", "Ball"); + AddChoice("structype.cross", "Cross"); + + // Radius AddParameter(ParameterType_Int, "xradius", "Structuring element X radius"); SetParameterDescription("xradius", "The structuring element radius along the X axis."); SetDefaultParameterInt("xradius", 5); @@ -105,43 +111,21 @@ private: SetParameterDescription("yradius", "The structuring element radius along the Y axis."); SetDefaultParameterInt("yradius", 5); - AddChoice("structype.box", "Box"); - AddChoice("structype.ball", "Ball"); - AddChoice("structype.cross", "Cross"); + // Foreground and background values + AddParameter(ParameterType_Float, "foreval", "Foreground value"); + SetParameterDescription("foreval", "Set the foreground value, default is 1.0."); + SetDefaultParameterFloat("foreval", 1.0); + AddParameter(ParameterType_Float, "backval", "Background value"); + SetParameterDescription("backval", "Set the background value, default is 0.0."); + SetDefaultParameterFloat("backval", 0.0); + // Morphological operations AddParameter(ParameterType_Choice, "filter", "Morphological Operation"); SetParameterDescription("filter", "Choice of the morphological operation"); - // Dilate AddChoice("filter.dilate", "Dilate"); - AddParameter(ParameterType_Float, "filter.dilate.foreval", "Foreground value"); - SetParameterDescription("filter.dilate.foreval", "Set the foreground value, default is 1.0."); - SetDefaultParameterFloat("filter.dilate.foreval", 1.0); - AddParameter(ParameterType_Float, "filter.dilate.backval", "Background value"); - SetParameterDescription("filter.dilate.backval", "Set the background value, default is 0.0."); - SetDefaultParameterFloat("filter.dilate.backval", 0.0); - - // Erode AddChoice("filter.erode", "Erode"); - AddParameter(ParameterType_Float, "filter.erode.foreval", "Foreground value"); - SetParameterDescription("filter.erode.foreval", "Set the foreground value, default is 1.0."); - SetDefaultParameterFloat("filter.erode.foreval", 1.0); - AddParameter(ParameterType_Float, "filter.erode.backval", "Background value"); - SetParameterDescription("filter.erode.backval", "Set the background value, default is 0.0."); - SetDefaultParameterFloat("filter.erode.backval", 0.0); - - // Opening AddChoice("filter.opening", "Opening"); - AddParameter(ParameterType_Float, "filter.opening.foreval", "Foreground value"); - SetParameterDescription("filter.opening.foreval", "Set the foreground value, default is 1.0."); - SetDefaultParameterFloat("filter.opening.foreval", 1.0); - AddParameter(ParameterType_Float, "filter.opening.backval", "Background value"); - SetParameterDescription("filter.opening.backval", "Set the background value, default is 0.0."); - SetDefaultParameterFloat("filter.opening.backval", 0.0); - // Closing AddChoice("filter.closing", "Closing"); - AddParameter(ParameterType_Float, "filter.closing.foreval", "Foreground value"); - SetParameterDescription("filter.closing.foreval", "Set the foreground value, default is 1.0."); - SetDefaultParameterFloat("filter.closing.foreval", 1.0); AddRAMParameter(); @@ -204,8 +188,8 @@ private: m_DilFilter = DilateFilterType::New(); m_DilFilter->SetKernel(se); m_DilFilter->SetInput(m_ExtractorFilter->GetOutput()); - m_DilFilter->SetForegroundValue(GetParameterFloat("filter.dilate.foreval")); - m_DilFilter->SetBackgroundValue(GetParameterFloat("filter.dilate.backval")); + m_DilFilter->SetForegroundValue(GetParameterFloat("foreval")); + m_DilFilter->SetBackgroundValue(GetParameterFloat("backval")); SetParameterOutputImage("out", m_DilFilter->GetOutput()); } else if (GetParameterString("filter") == "erode") @@ -213,8 +197,8 @@ private: m_EroFilter = ErodeFilterType::New(); m_EroFilter->SetKernel(se); m_EroFilter->SetInput(m_ExtractorFilter->GetOutput()); - m_EroFilter->SetForegroundValue(GetParameterFloat("filter.erode.foreval")); - m_EroFilter->SetBackgroundValue(GetParameterFloat("filter.erode.backval")); + m_EroFilter->SetForegroundValue(GetParameterFloat("foreval")); + m_EroFilter->SetBackgroundValue(GetParameterFloat("backval")); SetParameterOutputImage("out", m_EroFilter->GetOutput()); } else if (GetParameterString("filter") == "opening") @@ -222,8 +206,8 @@ private: m_OpeFilter = OpeningFilterType::New(); m_OpeFilter->SetKernel(se); m_OpeFilter->SetInput(m_ExtractorFilter->GetOutput()); - m_OpeFilter->SetForegroundValue(GetParameterFloat("filter.opening.foreval")); - m_OpeFilter->SetBackgroundValue(GetParameterFloat("filter.opening.backval")); + m_OpeFilter->SetForegroundValue(GetParameterFloat("foreval")); + m_OpeFilter->SetBackgroundValue(GetParameterFloat("backval")); SetParameterOutputImage("out", m_OpeFilter->GetOutput()); } else if (GetParameterString("filter") == "closing") @@ -231,7 +215,7 @@ private: m_CloFilter = ClosingFilterType::New(); m_CloFilter->SetKernel(se); m_CloFilter->SetInput(m_ExtractorFilter->GetOutput()); - m_CloFilter->SetForegroundValue(GetParameterFloat("filter.closing.foreval")); + m_CloFilter->SetForegroundValue(GetParameterFloat("foreval")); SetParameterOutputImage("out", m_CloFilter->GetOutput()); } } diff --git a/Modules/Applications/AppMorphology/test/CMakeLists.txt b/Modules/Applications/AppMorphology/test/CMakeLists.txt index 6f06d2987cf5b352ed7c34e917ec96c8a19ac648..cbeb6948533c9d7ecac5637163b9951aa803d4b1 100644 --- a/Modules/Applications/AppMorphology/test/CMakeLists.txt +++ b/Modules/Applications/AppMorphology/test/CMakeLists.txt @@ -27,8 +27,8 @@ otb_test_application(NAME apTvFEBinaryMorphologicalOperation -structype ball -xradius 10 -filter opening - -filter.opening.foreval 1.0 - -filter.opening.backval 0.0 + -foreval 1.0 + -backval 0.0 -out ${TEMP}/apTvFEBinaryMorphologicalOperation.tif VALID --compare-image ${NOTOL} ${BASELINE}/apTvFEBinaryMorphologicalOperation.tif