diff --git a/Code/FeatureExtraction/otbAssociativeSymmetricalSumImageFilter.h b/Code/FeatureExtraction/otbAssociativeSymmetricalSumImageFilter.h index 89bf489e8e69ce417074572580550bfe8a57ec14..aa8fb011ab7c504abf9aaa0857b7a503bba0a94b 100755 --- a/Code/FeatureExtraction/otbAssociativeSymmetricalSumImageFilter.h +++ b/Code/FeatureExtraction/otbAssociativeSymmetricalSumImageFilter.h @@ -29,7 +29,7 @@ namespace otb * This class implements a fusion of the output images of * otb::LineRatioDetector and otb::LineCorrelationDetector * - * The assaciative symmetrical sum \f$ \sigma(x,y) \f$ is used to merge information from the + * The associative symmetrical sum \f$ \sigma(x,y) \f$ is used to merge information from the * two detectors: \f[ \sigma(x,y)=\frac{xy}{1-x-y+2xy} \f] with \f$ x,y \in [0,1] \f$. * diff --git a/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.h b/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..c9bd86ca63593ac50a9085245eb7fe53b24cc9ee --- /dev/null +++ b/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.h @@ -0,0 +1,174 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef _otbGeodesicMorphologyDecompositionImageFilter_h +#define _otbGeodesicMorphologyDecompositionImageFilter_h + +#include "itkImageToImageFilter.h" +#include "otbGeodesicMorphologyLevelingFilter.h" +#include "itkSubtractImageFilter.h" +#include "itkOpeningByReconstructionImageFilter.h" +#include "itkClosingByReconstructionImageFilter.h" +#include "otbMacro.h" + +namespace otb +{ +/** \class GeodesicMorphologyDecompositionImageFilter + * \brief This class implements a geodesic morphology based image analysis algorithm. + * \par + * This algorithm is based on the following publication: + * \par + * Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: + * A new approach for the morphological segmentation of high resolution + * satellite imagery. IEEE Transactions on geoscience and remote sensing, vol. 39, + * NO. 2, February 2001, p. 309-320. + * \par + * + * Given \f$\gamma^{\star}_{N}\f$ the geodesic opening by reconstruction morphological operator + * and \f$\varphi^{\star}_{N}\f$ the geodesic closing by reconstruction morphological operator + * for a structuring element of size \f$N\f$, one can define the two following membership functions for + * the input image \f$f\f$: + * + * \f[ + * \stackrel{\smile}{\mu} = f-\gamma^{\star}_{N}(f) + * \stackrel{\frown}{\mu} = \phi^{\star}_{N}(f)-f + * \f] + * + * Where \f$\stackrel{\smile}{\mu}\f$ denotes the likelihood of the current pixel to belong to a convex structure + * of the input image \f$f\f$ (i.e. brighter than the surrounding background) with respect to the size of the + * structuring element \f$N\f$, and \f$\stackrel{\frown}{\mu}\f$ denotes the likekihood of the current pixel to + * belong to a concave structure. + * + * This two membership functions can be used to define a simplification operator \f$\psi_{N}\f$ called leveling, + * which removes from the input image \f$f\f$ the structures located by \f$\stackrel{\smile}{\mu}\f$ and + * \f$\stackrel{\frown}{\mu}\f$: + * + * \f[ + * \psi_{N}(f)= \left{\begin{array}{lcl} + * \gamma^{\star}_{N}(f)&:& \stackrel{\smile}{\mu}>\stackrel{\frown}{\mu}\\ + * \varphi^{\star}_{N}(f)&:& \stackrel{\frown}{\mu}>\stackrel{\smile}{\mu}\\ + * f&:&\stackrel{\frown}{\mu}=\stackrel{\smile}{\mu} + * \end{array}\right. + * \f] + * + * This filter performs this image decomposition at a given structuring element size. The GetOutput() method returns + * \f$\psi_{N}(f)\f$, the GetConvexMap() method returns \f$\stackrel{\smile}{\mu}\f$ and the GetConcaveMap() method + * returns \f$\stackrel{\frown}{\mu}\f$. + * + * The PreserveIntensities and the FullyConnected flags reflects the option of the geodesic morphology filters from ITK. + * + * \sa GeodesicMorphologyLevelingFilter + * \sa itk::OpeningByReconstructionImageFilter + * \sa itk::ClosingByReconstructionImageFilter + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +class ITK_EXPORT GeodesicMorphologyDecompositionImageFilter + : public itk::ImageToImageFilter<TInputImage,TOutputImage> +{ + public: + /** Standard typedefs */ + typedef GeodesicMorphologyDecompositionImageFilter Self; + typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(GeodesicMorphologyDecompositionImageFilter, ImageToImageFilter); + + /** Template parameters typedefs */ + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + + typedef TStructuringElement StructuringElementType; + typedef typename StructuringElementType::RadiusType RadiusType; + typedef itk::OpeningByReconstructionImageFilter<InputImageType,InputImageType,StructuringElementType> OpeningFilterType; + typedef itk::ClosingByReconstructionImageFilter<InputImageType,InputImageType,StructuringElementType> ClosingFilterType; + typedef itk::SubtractImageFilter<InputImageType,InputImageType,OutputImageType> ConvexFilterType; + typedef itk::SubtractImageFilter<OutputImageType,InputImageType,OutputImageType> ConcaveFilterType; + typedef otb::GeodesicMorphologyLevelingFilter<InputImageType,OutputImageType,OutputImageType> LevelingFilterType; + + /** Pointers typedefs*/ + typedef typename OpeningFilterType::Pointer OpeningFilterPointerType; + typedef typename ClosingFilterType::Pointer ClosingFilterPointerType; + typedef typename LevelingFilterType::Pointer LevelingFilterPointerType; + typedef typename ConvexFilterType::Pointer ConvexFilterPointerType; + typedef typename ConcaveFilterType::Pointer ConcaveFilterPointerType; + + /** Radius of the structuring element */ + itkSetMacro(Radius,RadiusType); + itkGetConstReferenceMacro(Radius,RadiusType); + + /** + * Get the convex likehood map. + * \return The convex likehood map. + */ + OutputImageType * GetConvexMap(void); + + /** + * Get the concave likehood map. + * \return The concave likehood map. + */ + OutputImageType * GetConcaveMap(void); + + /** FullyConnected flag */ + itkSetMacro(FullyConnected,bool); + itkGetMacro(FullyConnected,bool); + /** Preserve intensities flag */ + itkSetMacro(PreserveIntensities,bool); + itkGetMacro(PreserveIntensities,bool); + +protected: + /** GenerateData */ + virtual void GenerateData(void); + /** Constructor */ + GeodesicMorphologyDecompositionImageFilter(); + /** Destructor */ + virtual ~GeodesicMorphologyDecompositionImageFilter() {}; + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + GeodesicMorphologyDecompositionImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + /** Radius of the structuring element */ + RadiusType m_Radius; + /** Opening filter */ + OpeningFilterPointerType m_OpeningFilter; + /** Closing filter */ + ClosingFilterPointerType m_ClosingFilter; + /** First subtract filter (output is the convex map)*/ + ConvexFilterPointerType m_ConvexFilter; + /** Second subtract filter (output is the concave map) */ + ConcaveFilterPointerType m_ConcaveFilter; + /** Leveling function */ + LevelingFilterPointerType m_LevelingFilter; + /** Preserve intensities in morphological operators */ + bool m_PreserveIntensities; + /** Use fully connected morphological operators */ + bool m_FullyConnected; + +}; +}// End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbGeodesicMorphologyDecompositionImageFilter.txx" +#endif + +#endif diff --git a/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.txx b/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..8f5b33e07d97634dcd3e8ab8978c8d2ef3e24bfa --- /dev/null +++ b/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.txx @@ -0,0 +1,136 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef _otbGeodesicMorphologyDecompositionImageFilter_txx +#define _otbGeodesicMorphologyDecompositionImageFilter_txx + +#include "otbGeodesicMorphologyDecompositionImageFilter.h" + +namespace otb +{ +/** + * Constructor + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +GeodesicMorphologyDecompositionImageFilter<TInputImage,TOutputImage,TStructuringElement> +::GeodesicMorphologyDecompositionImageFilter() +{ + this->SetNumberOfOutputs(3); + this->SetNthOutput(0,OutputImageType::New()); + this->SetNthOutput(1,OutputImageType::New()); + this->SetNthOutput(2,OutputImageType::New()); + + m_Radius.Fill(1); + + m_OpeningFilter = OpeningFilterType::New(); + m_ClosingFilter = ClosingFilterType::New(); + m_LevelingFilter = LevelingFilterType::New(); + m_ConvexFilter = ConvexFilterType::New(); + m_ConcaveFilter = ConcaveFilterType::New(); + + m_FullyConnected = true; + m_PreserveIntensities = true; +} +/** + * Main computation method + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +void +GeodesicMorphologyDecompositionImageFilter<TInputImage,TOutputImage,TStructuringElement> +::GenerateData() +{ + StructuringElementType se; + se.SetRadius(m_Radius); + se.CreateStructuringElement(); + + m_OpeningFilter->SetInput(this->GetInput()); + m_OpeningFilter->SetKernel(se); + m_OpeningFilter->SetPreserveIntensities(m_PreserveIntensities); + m_OpeningFilter->SetFullyConnected(m_FullyConnected); + + m_ClosingFilter->SetInput(this->GetInput()); + m_ClosingFilter->SetKernel(se); + m_ClosingFilter->SetPreserveIntensities(m_PreserveIntensities); + m_ClosingFilter->SetFullyConnected(m_FullyConnected); + + m_ConvexFilter->SetInput1(this->GetInput()); + m_ConvexFilter->SetInput2(m_OpeningFilter->GetOutput()); + + m_ConcaveFilter->SetInput1(m_ClosingFilter->GetOutput()); + m_ConcaveFilter->SetInput2(this->GetInput()); + + m_LevelingFilter->SetInput(this->GetInput()); + m_LevelingFilter->SetInputConvexMap(m_ConvexFilter->GetOutput()); + m_LevelingFilter->SetInputConcaveMap(m_ConcaveFilter->GetOutput()); + + m_ConvexFilter->GraftOutput(this->GetConvexMap()); + m_ConvexFilter->Update(); + this->GraftNthOutput(1,m_ConvexFilter->GetOutput()); + + m_ConcaveFilter->GraftOutput(this->GetConcaveMap()); + m_ConcaveFilter->Update(); + this->GraftNthOutput(2,m_ConcaveFilter->GetOutput()); + + m_LevelingFilter->GraftOutput(this->GetOutput()); + m_LevelingFilter->Update(); + this->GraftOutput(m_LevelingFilter->GetOutput()); +} + +/** + * Get the convex map + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +TOutputImage * +GeodesicMorphologyDecompositionImageFilter<TInputImage,TOutputImage,TStructuringElement> +::GetConvexMap() +{ + if (this->GetNumberOfOutputs() < 2) + { + return 0; + } + return static_cast<OutputImageType * > + (this->itk::ProcessObject::GetOutput(1)); +} + +/** + * Get the concave map + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +TOutputImage * +GeodesicMorphologyDecompositionImageFilter<TInputImage,TOutputImage,TStructuringElement> +::GetConcaveMap() +{ + if (this->GetNumberOfOutputs() < 3) + { + return 0; + } + return static_cast<OutputImageType * > + (this->itk::ProcessObject::GetOutput(2)); +} + +/** + * PrintSelf Method + */ +template <class TInputImage, class TOutputImage, class TStructuringElement> +void +GeodesicMorphologyDecompositionImageFilter<TInputImage,TOutputImage,TStructuringElement> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} +} // End namespace otb +#endif diff --git a/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.h b/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..7706593d73cc0d83ccf1729fd01fb42ff11bba1b --- /dev/null +++ b/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.h @@ -0,0 +1,134 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef _otbGeodesicMorphologyLevelingFilter_h +#define _otbGeodesicMorphologyLevelingFilter_h + + +#include "itkTernaryFunctorImageFilter.h" + +namespace otb +{ +namespace Functor + { + /** \class LevelingFunctor + * \brief This functor performs the pixel-wise leveling operation needed in the + * geodesic morphology decomposition filter. For more details, please refer to + * the documentation of this filter. + * \sa GeodesicMorphologyDecompositionImageFilter + */ + template <class TInput, class TInputMap, class TOutput> + class LevelingFunctor + { + public: + /// Constructor + LevelingFunctor(){}; + /// Destructor + ~LevelingFunctor(){}; + + inline TOutput operator()(const TInput& pixel, const TInputMap& convexPixel, const TInputMap& concavePixel) + { + TOutput result; + + if(convexPixel>concavePixel) + { + result = static_cast<TOutput>(pixel-convexPixel); + } + else if(convexPixel<concavePixel) + { + result = static_cast<TOutput>(concavePixel+pixel); + } + else + { + result = static_cast<TOutput>(pixel); + } + return result; + } + }; + }// end namespace Functor + +/** \class GeodesicMorphologyLevelingFilter + * \brief This filter performs the leveling operation defined in the documentation of + * the geodesic decomposition image filter, given the original image, convex and concave membership + * functions. Please refer to the documentation of this filter for more details. + * + * \sa GeodesicMorphologyDecompositionImageFilter + */ +template <class TInputImage, class TInputMaps, class TOutputImage> +class ITK_EXPORT GeodesicMorphologyLevelingFilter + : public itk::TernaryFunctorImageFilter<TInputImage,TInputImage, + TInputImage,TOutputImage, + Functor::LevelingFunctor<typename TInputImage::PixelType, + typename TInputMaps::PixelType, + typename TOutputImage::PixelType> > +{ + public: + /** Standard typedefs */ + typedef GeodesicMorphologyLevelingFilter Self; + typedef itk::TernaryFunctorImageFilter<TInputImage,TInputImage, + TInputImage,TOutputImage, + Functor::LevelingFunctor<typename TInputImage::PixelType, + typename TInputMaps::PixelType, + typename TOutputImage::PixelType> >Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(GeodesicMorphologyLevelingFilter,TernaryFunctorImageFilter); + + /** + * Set the convex membership image. + */ + void SetInputConvexMap(const TInputMaps * convexMap) + { + this->SetInput2(convexMap); + } + /** + * Set the concave membership image. + */ + void SetInputConcaveMap(const TInputMaps * concaveMap) + { + this->SetInput3(concaveMap); + } + /** + * Set the original input image + */ + void SetInput(const TInputImage * input) + { + this->SetInput1(input); + } + +protected: + /** Constructor */ + GeodesicMorphologyLevelingFilter(){}; + /** Destructor */ + virtual ~GeodesicMorphologyLevelingFilter() {}; + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os,indent); + } + +private: + GeodesicMorphologyLevelingFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +}// End namespace otb +#endif diff --git a/Testing/Code/MultiScale/CMakeLists.txt b/Testing/Code/MultiScale/CMakeLists.txt index 2d0ceff93ca72099181a07471a86bf85489fbcff..9e3ec67fbb36820341db59f788064cf77a6e72cf 100644 --- a/Testing/Code/MultiScale/CMakeLists.txt +++ b/Testing/Code/MultiScale/CMakeLists.txt @@ -162,7 +162,42 @@ ADD_TEST(msTvMorphoPyrSegmentationFilter ${MULTISCALE_TESTS2} 10 ) +# ------- otb::GeodesicMorphologyDecompositionImageFilter ---------- + +ADD_TEST(msTuGeodesicMorphologyDecompositionImageFilterNew ${MULTISCALE_TESTS2} + otbGeodesicMorphologyDecompositionImageFilterNew) + +ADD_TEST(msTvGeodesicMorphologyDecompositionImageFilter ${MULTISCALE_TESTS2} + --compare-n-images ${TOL} 3 + ${BASELINE}/msGeodesicMorphologyDecompositionImageFilterConvexOutput.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterConvexOutput.tif + ${BASELINE}/msGeodesicMorphologyDecompositionImageFilterConcaveOutput.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterConcaveOutput.tif + ${BASELINE}/msGeodesicMorphologyDecompositionImageFilterLevelingOutput.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterLevelingOutput.tif + otbGeodesicMorphologyDecompositionImageFilter + ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterConvexOutput.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterConcaveOutput.tif + ${TEMP}/msGeodesicMorphologyDecompositionImageFilterLevelingOutput.tif + 4 +) +# ------- otb::GeodesicMorphologyLevelingFilter ---------- + +ADD_TEST(msTuGeodesicMorphologyLevelingFilterNew ${MULTISCALE_TESTS2} + otbGeodesicMorphologyLevelingFilterNew) + +ADD_TEST(msTvGeodesicMorphologyLevelingFilter ${MULTISCALE_TESTS2} + --compare-image ${TOL} + ${BASELINE}/msGeodesicMorphologyLevelingFilterOutput.tif + ${TEMP}/msGeodesicMorphologyLevelingFilterOutput.tif + otbGeodesicMorphologyLevelingFilter + ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + ${INPUTDATA}/ROI_IKO_PAN_LesHalles_convex.tif + ${INPUTDATA}/ROI_IKO_PAN_LesHalles_concave.tif + ${TEMP}/msGeodesicMorphologyLevelingFilterOutput.tif +) # ------- Fichiers sources CXX ----------------------------------- SET(BasicMultiScale_SRCS1 @@ -180,6 +215,10 @@ otbMorphologicalPyramidSegmenter.cxx SET(BasicMultiScale_SRCS2 otbMorphologicalPyramidSegmentationFilterNew.cxx otbMorphologicalPyramidSegmentationFilter.cxx +otbGeodesicMorphologyDecompositionImageFilterNew.cxx +otbGeodesicMorphologyDecompositionImageFilter.cxx +otbGeodesicMorphologyLevelingFilterNew.cxx +otbGeodesicMorphologyLevelingFilter.cxx ) diff --git a/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.cxx b/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..050022a508f8b80566474242ffe9297641d70a3b --- /dev/null +++ b/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilter.cxx @@ -0,0 +1,73 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "otbGeodesicMorphologyDecompositionImageFilter.h" +#include "otbGeodesicMorphologyDecompositionImageFilter.h" +#include "otbImageFileReader.h" +#include "otbStreamingImageFileWriter.h" +#include "otbImage.h" +#include "itkBinaryBallStructuringElement.h" + +int otbGeodesicMorphologyDecompositionImageFilter(int argc, char * argv[]) +{ + + const char * infname = argv[1]; + const char * convexfname = argv[2]; + const char * concavefname = argv[3]; + const char * levelingfname = argv[4]; + const unsigned int sesize = atoi(argv[5]); + + typedef otb::Image<double,2> ImageType; + typedef itk::BinaryBallStructuringElement<double,2> StructuringElementType; + typedef StructuringElementType::RadiusType RadiusType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::StreamingImageFileWriter<ImageType> WriterType; + typedef otb::GeodesicMorphologyDecompositionImageFilter<ImageType,ImageType,StructuringElementType> GeodesicMorphologyDecompositionImageFilterType; + + // Instantiating object + GeodesicMorphologyDecompositionImageFilterType::Pointer filter = GeodesicMorphologyDecompositionImageFilterType::New(); + + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(infname); + + filter->SetInput(reader->GetOutput()); + + RadiusType radius; + radius.Fill(sesize); + + filter->SetRadius(radius); + + // writer the leveling map + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(levelingfname); + writer->SetInput(filter->GetOutput()); + writer->Update(); + + // write the convex map + writer = WriterType::New(); + writer->SetFileName(convexfname); + writer->SetInput(filter->GetConvexMap()); + writer->Update(); + + // write the concave map + writer = WriterType::New(); + writer->SetFileName(concavefname); + writer->SetInput(filter->GetConcaveMap()); + writer->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilterNew.cxx b/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5ea0ab1c5a84468cb0cd5cdd69b80746a1101875 --- /dev/null +++ b/Testing/Code/MultiScale/otbGeodesicMorphologyDecompositionImageFilterNew.cxx @@ -0,0 +1,31 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "otbGeodesicMorphologyDecompositionImageFilter.h" +#include "otbImage.h" +#include "itkBinaryBallStructuringElement.h" + +int otbGeodesicMorphologyDecompositionImageFilterNew(int argc, char * argv[]) +{ + typedef otb::Image<double,2> ImageType; + typedef itk::BinaryBallStructuringElement<double,2> StructuringElementType; + typedef otb::GeodesicMorphologyDecompositionImageFilter<ImageType,ImageType,StructuringElementType> GeodesicMorphologyDecompositionImageFilterType; + + // Instantiating object + GeodesicMorphologyDecompositionImageFilterType::Pointer filter = GeodesicMorphologyDecompositionImageFilterType::New(); + return EXIT_SUCCESS; +} diff --git a/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.cxx b/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..74b38c07dbd240ea76ce525ffe4b5cb391cd63af --- /dev/null +++ b/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilter.cxx @@ -0,0 +1,58 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "otbGeodesicMorphologyLevelingFilter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbGeodesicMorphologyLevelingFilter(int argc, char * argv[]) +{ + const char * infname = argv[1]; + const char * inconvfname = argv[2]; + const char * inconcfname = argv[3]; + const char * outfname = argv[4]; + + typedef otb::Image<double,2> ImageType; + typedef otb::GeodesicMorphologyLevelingFilter<ImageType,ImageType,ImageType> FilterType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + + ReaderType::Pointer convreader,concreader,reader; + reader = ReaderType::New(); + convreader = ReaderType::New(); + concreader = ReaderType::New(); + + reader->SetFileName(infname); + convreader->SetFileName(inconvfname); + concreader->SetFileName(inconcfname); + + FilterType::Pointer filter = FilterType::New(); + + filter->SetInput(reader->GetOutput()); + filter->SetInputConvexMap(convreader->GetOutput()); + filter->SetInputConcaveMap(concreader->GetOutput()); + + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(outfname); + writer->SetInput(filter->GetOutput()); + writer->Update(); + + + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilterNew.cxx b/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bbc87a7862c411e9486bd25cec086bcd9cc2cac4 --- /dev/null +++ b/Testing/Code/MultiScale/otbGeodesicMorphologyLevelingFilterNew.cxx @@ -0,0 +1,29 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "otbGeodesicMorphologyLevelingFilter.h" +#include "otbImage.h" + +int otbGeodesicMorphologyLevelingFilterNew(int argc, char * argv[]) +{ + typedef otb::Image<double,2> ImageType; + typedef otb::GeodesicMorphologyLevelingFilter<ImageType,ImageType,ImageType> FilterType; + + FilterType::Pointer filter = FilterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/MultiScale/otbMultiScaleTests2.cxx b/Testing/Code/MultiScale/otbMultiScaleTests2.cxx index 2ff59c143fb25805398e1721aec6aa23819c1161..a04c5d2ddec994236d8deb4d5279a659a53d472c 100644 --- a/Testing/Code/MultiScale/otbMultiScaleTests2.cxx +++ b/Testing/Code/MultiScale/otbMultiScaleTests2.cxx @@ -28,4 +28,8 @@ void RegisterTests() { REGISTER_TEST(otbMorphologicalPyramidSegmentationFilterNew); REGISTER_TEST(otbMorphologicalPyramidSegmentationFilter); +REGISTER_TEST(otbGeodesicMorphologyDecompositionImageFilterNew); +REGISTER_TEST(otbGeodesicMorphologyDecompositionImageFilter); +REGISTER_TEST(otbGeodesicMorphologyLevelingFilterNew); +REGISTER_TEST(otbGeodesicMorphologyLevelingFilter); }