diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index c8c975c57148fcd2ad4c2c7f5ed4d878dd9ffab8..2f7a76a4e0dea23bd59f2bb64101c360487f1368 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -39,6 +39,7 @@ #include "otbOGRLayerStreamStitchingFilter.h" #include "otbGeoInformationConversion.h" +#include "otbClampImageFilter.h" //Utils #include "itksys/SystemTools.hxx" @@ -129,6 +130,8 @@ public: <FloatImageType, WatershedSegmentationFilterType> StreamingVectorizedWatershedFilterType; + typedef otb::ClampImageFilter<FloatImageType, UInt32ImageType> ClampFilterType; + /** Standard macro */ itkNewMacro(Self); itkTypeMacro(Segmentation, otb::Application); @@ -369,7 +372,7 @@ private: if (segModeType == "vector" && HasValue("mode.vector.inmask")) { - streamingVectorizedFilter->SetInputMask(this->GetParameterUInt32Image("mode.vector.inmask")); + streamingVectorizedFilter->SetInputMask(m_ClampFilter->GetOutput()); otbAppLogINFO(<<"Use a mask as input." << std::endl); } streamingVectorizedFilter->SetOGRLayer(layer); @@ -547,6 +550,13 @@ private: } } + // handle mask + if (HasValue("mode.vector.inmask")) + { + m_ClampFilter = ClampFilterType::New(); + m_ClampFilter->SetInput( this->GetParameterFloatImage("mode.vector.inmask")); + } + // The actual stream size used FloatVectorImageType::SizeType streamSize; @@ -559,7 +569,7 @@ private: if (HasValue("mode.vector.inmask")) { ccVectorizationFilter->GetSegmentationFilter()->SetMaskImage( - this->GetParameterUInt32Image("mode.vector.inmask")); + m_ClampFilter->GetOutput()); } ccVectorizationFilter->GetSegmentationFilter()->GetFunctor().SetExpression(GetParameterString("filter.cc.expr")); @@ -696,6 +706,8 @@ private: } } } + + ClampFilterType::Pointer m_ClampFilter; }; } }