Commit 89db766b authored by Guillaume Pasero's avatar Guillaume Pasero

BUG: avoid overkill MuParser to perform simple affine function (avoid 4-digits...

BUG: avoid overkill MuParser to perform simple affine function (avoid 4-digits MuParser issue on MacOSX)
parent 8c54cfc7
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
#include "otbMultiChannelExtractROI.h" #include "otbMultiChannelExtractROI.h"
#include "otbExtractROI.h" #include "otbExtractROI.h"
#include "otbConnectedComponentMuParserFunctor.h" #include "otbConnectedComponentMuParserFunctor.h"
#include "otbBandMathImageFilter.h"
#include "itkUnaryFunctorImageFilter.h" #include "itkUnaryFunctorImageFilter.h"
#include "itkStatisticsImageFilter.h" #include "itkStatisticsImageFilter.h"
#include "itkChangeLabelImageFilter.h" #include "itkChangeLabelImageFilter.h"
#include "itkImageRegionConstIterator.h" #include "itkImageRegionConstIterator.h"
#include "itkScalarConnectedComponentImageFilter.h" #include "itkScalarConnectedComponentImageFilter.h"
#include "otbConcatenateVectorImageFilter.h" #include "otbConcatenateVectorImageFilter.h"
#include "otbAffineFunctor.h"
#include "otbMultiToMonoChannelExtractROI.h" #include "otbMultiToMonoChannelExtractROI.h"
#include "otbImportGeoInformationImageFilter.h" #include "otbImportGeoInformationImageFilter.h"
...@@ -70,13 +70,20 @@ public: ...@@ -70,13 +70,20 @@ public:
typedef otb::Functor::ConnectedComponentMuParserFunctor<ImageType::PixelType> CCFunctorType; typedef otb::Functor::ConnectedComponentMuParserFunctor<ImageType::PixelType> CCFunctorType;
typedef itk::ConnectedComponentFunctorImageFilter<ImageType, LabelImageType, CCFunctorType, otb::Image<unsigned int> > CCFilterType; typedef itk::ConnectedComponentFunctorImageFilter<ImageType, LabelImageType, CCFunctorType, otb::Image<unsigned int> > CCFilterType;
typedef itk::ScalarConnectedComponentImageFilter<LabelImageType, LabelImageType> ScalarCCFilterType; typedef itk::ScalarConnectedComponentImageFilter<LabelImageType, LabelImageType> ScalarCCFilterType;
typedef otb::BandMathImageFilter<LabelImageType> BandMathImageFilterType;
typedef itk::StatisticsImageFilter<LabelImageType> StatisticsImageFilterType; typedef itk::StatisticsImageFilter<LabelImageType> StatisticsImageFilterType;
typedef itk::ChangeLabelImageFilter<LabelImageType,LabelImageType> ChangeLabelImageFilterType; typedef itk::ChangeLabelImageFilter<LabelImageType,LabelImageType> ChangeLabelImageFilterType;
typedef otb::ImportGeoInformationImageFilter<LabelImageType,ImageType> ImportGeoInformationImageFilterType; typedef otb::ImportGeoInformationImageFilter<LabelImageType,ImageType> ImportGeoInformationImageFilterType;
typedef itk::ImageRegionConstIterator<LabelImageType> LabelImageIterator; typedef itk::ImageRegionConstIterator<LabelImageType> LabelImageIterator;
typedef otb::ConcatenateVectorImageFilter <ImageType,ImageType,ImageType> ConcatenateType; typedef otb::ConcatenateVectorImageFilter <ImageType,ImageType,ImageType> ConcatenateType;
typedef otb::Functor::AffineFunctor<
LabelImagePixelType,
LabelImagePixelType,
LabelImagePixelType> AffineFunctorType;
typedef itk::UnaryFunctorImageFilter<
LabelImageType,
LabelImageType,
AffineFunctorType> LabelShiftFilterType;
LSMSSegmentation(): m_FinalReader(),m_ImportGeoInformationFilter(),m_FilesToRemoveAfterExecute(),m_TmpDirCleanup(false){} LSMSSegmentation(): m_FinalReader(),m_ImportGeoInformationFilter(),m_FilesToRemoveAfterExecute(),m_TmpDirCleanup(false){}
...@@ -401,14 +408,12 @@ private: ...@@ -401,14 +408,12 @@ private:
ccFilter->GetFunctor().SetExpression(expr.str()); ccFilter->GetFunctor().SetExpression(expr.str());
ccFilter->Update(); ccFilter->Update();
std::stringstream ssexpr;
ssexpr<<"label+"<<regionCount;
//Shifting //Shifting
BandMathImageFilterType::Pointer labelBandMath = BandMathImageFilterType::New(); LabelShiftFilterType::Pointer labelShiftFilter = LabelShiftFilterType::New();
labelBandMath->SetNthInput(0,ccFilter->GetOutput(),"label"); labelShiftFilter->SetInput(ccFilter->GetOutput());
labelBandMath->SetExpression(ssexpr.str()); labelShiftFilter->GetFunctor().SetA(1);
labelBandMath->Update(); labelShiftFilter->GetFunctor().SetB(regionCount);
labelShiftFilter->Update();
//Maximum label calculation for the shifting //Maximum label calculation for the shifting
StatisticsImageFilterType::Pointer stats = StatisticsImageFilterType::New(); StatisticsImageFilterType::Pointer stats = StatisticsImageFilterType::New();
...@@ -416,7 +421,7 @@ private: ...@@ -416,7 +421,7 @@ private:
stats->Update(); stats->Update();
regionCount+=stats->GetMaximum(); regionCount+=stats->GetMaximum();
std::string filename = WriteTile(labelBandMath->GetOutput(),row,column,"SEG"); std::string filename = WriteTile(labelShiftFilter->GetOutput(),row,column,"SEG");
} }
......
...@@ -17,7 +17,6 @@ otb_module(OTBAppSegmentation ...@@ -17,7 +17,6 @@ otb_module(OTBAppSegmentation
OTBGdalAdapters OTBGdalAdapters
OTBApplicationEngine OTBApplicationEngine
OTBImageBase OTBImageBase
OTBMathParser
OTBCommon OTBCommon
OTBImageManipulation OTBImageManipulation
OTBMorphologicalProfiles OTBMorphologicalProfiles
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment