diff --git a/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.h b/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..74fd198c0f9b556433bcbedc26a58c9df7988af1 --- /dev/null +++ b/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.h @@ -0,0 +1,155 @@ +/*========================================================================= + +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 _otbNonMaxRemovalByDirectionFilter_h +#define _otbNonMaxRemovalByDirectionFilter_h + +#include "otbModulusAndDirectionImageToImageFilter.h" +#include "otbBinaryFunctorNeighborhoodImageFilter.h" + +#ifndef M_PI +#define M_PI vcl_acos(-1.0) +#endif + +namespace otb +{ +namespace Functor + { + /** \class NonMaxRemovalByDirectionFunctor + * \brief This functor is used by the NonMaxRemovalByDirectionFilter + * \sa NonMaxRemovalByDirectionFilter + * \ingroup Functor + */ + template <class TInput1, class TInput2, class TOutput> + class NonMaxRemovalByDirectionFunctor + { + public: + NonMaxRemovalByDirectionFunctor() {}; + ~NonMaxRemovalByDirectionFunctor() {}; + inline TOutput operator()(const TInput1 & itA, const TInput2 &itB) + { + if (itA.GetCenterPixel() != 0) + { + typename TInput1::OffsetType offset1,offset2; + int neighborhoodNumber; + if (itB.GetCenterPixel() > 0) + { + neighborhoodNumber = static_cast<int>(itB.GetCenterPixel()/(M_PI/4)-1); + } + else + { + neighborhoodNumber = static_cast<int>((itB.GetCenterPixel()+M_PI)/(M_PI/4)-1); + } + switch( neighborhoodNumber ) + { + case 0: + offset1[0] = 1; + offset1[1] = -1; + offset2[0] = -1; + offset2[1] = 1; + break; + case 1: + offset1[0] = 1; + offset1[1] = 0; + offset2[0] = -1; + offset2[1] = 0; + break; + case 2: + offset1[0] = 1; + offset1[1] = 1; + offset2[0] = -1; + offset2[1] = -1; + break; + case 3: + offset1[0] = 0; + offset1[1] = 1; + offset2[0] = 0; + offset2[1] = -1; + break; + } + if ((itA.GetCenterPixel() > itA.GetPixel(offset1)) + && (itA.GetCenterPixel() > itA.GetPixel(offset2))) + { + return itA.GetCenterPixel(); + } + else + { + return 0; + } + } + } + }; + } +/** \class NonMaxRemovalByDirectionFilter + * \brief This filters removes (sets to null intensity) pixels which are not the maxima of the + * scalar product modulus value in the given direction. + * + * \ingroup Streamed + * \ingroup Threaded + */ +template <class TInputModulus, class TInputDirection, class TOutputImage> +class ITK_EXPORT NonMaxRemovalByDirectionFilter + : public ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> +{ + public: + /** Standard typedefs */ + typedef NonMaxRemovalByDirectionFilter Self; + typedef ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(NonMaxRemovalByDirectionFilter,ModulusAndDirectionImageToImageFilter); + + /** typedef of the computing filter (this allows us to derive from ModulusAndDirectionToImageFilter as well as + using the BinaryFunctorNeighBorhoodImageFilter, which is appropriate here */ + typedef Functor::NonMaxRemovalByDirectionFunctor< + typename itk::ConstNeighborhoodIterator<TInputModulus>, + typename itk::ConstNeighborhoodIterator<TInputDirection>, + typename TOutputImage::PixelType> FunctorType; + typedef otb::BinaryFunctorNeighborhoodImageFilter<TInputModulus, TInputDirection,TOutputImage,FunctorType> ComputingFilterType; + +protected: + /** Constructor */ + NonMaxRemovalByDirectionFilter(){}; + /** Destructor */ + virtual ~NonMaxRemovalByDirectionFilter() {}; + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os,indent); + }; + /** Main computation method */ + virtual void GenerateData(void) + { + typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); + filter->SetInput1(this->GetInput()); + filter->SetInput2(this->GetInputDirection()); + filter->GraftOutput(this->GetOutput()); + filter->Update(); + this->GraftOutput(filter->GetOutput()); + } + +private: + NonMaxRemovalByDirectionFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +}// End namespace otb +#endif diff --git a/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.h b/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..379d4ca63f6b7c63d8ce97f191c89bdb6c1ade80 --- /dev/null +++ b/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.h @@ -0,0 +1,126 @@ +/*========================================================================= + +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 _otbRemoveIsolatedByDirectionFilter_h +#define _otbRemoveIsolatedByDirectionFilter_h + +#include "otbModulusAndDirectionImageToImageFilter.h" +#include "otbBinaryFunctorNeighborhoodImageFilter.h" + +namespace otb +{ +namespace Functor + { + /** \class RemoveIsolatedByDirectionFunctor + * \brief Binary neighborhood functor to remove isolated pixels by direction. + * Used by the RemoveIsolatedByDirectionFilter. + * \sa RemoveIsolatedByDirectionFilter + * \ingroup Functor + */ + template <class TInput1, class TInput2, class TOutput> + class RemoveIsolatedByDirectionFunctor + { + public: + RemoveIsolatedByDirectionFunctor() {}; + ~RemoveIsolatedByDirectionFunctor() {}; + inline TOutput operator()(const TInput1 & itA, const TInput2 &itB) + { + double currentDirection = itB.GetCenterPixel(); + int nEqualNeighbors = 0; + for (int neighborhoodIndex=0; neighborhoodIndex < 9; ++neighborhoodIndex) + { + if (itB.GetPixel(neighborhoodIndex) == currentDirection) + { + ++nEqualNeighbors; + } + } + if (nEqualNeighbors <= 1) + { + //should never be 0 as it is at least equal to itself + return 0; + } + else + { + return static_cast<TOutput>(itA.GetCenterPixel()); + } + } + }; + } +/** \class RemoveIsolatedByDirectionFilter + * \brief This filter removes (sets to null intensity) pixels isolated by direction. + * + * For a given pixel, the filter walk through its neighborhood in direction image, counting pixels having + * the same direction as the center pixel. If there is no such a pixel, the center pixel is considered to be + * isolated in direction, and thus will be removed (set to 0). If the pixel is not isolated in direction, the output + * value is the value of the pixel in the modulus image. + * Of course this filter requires the direction to be discrete, in order to be able to count the directions. + * + * \ingroup Streamed + * \ingroup Threaded + */ +template <class TInputModulus, class TInputDirection, class TOutputImage> +class ITK_EXPORT RemoveIsolatedByDirectionFilter + : public ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> +{ + public: + /** Standard typedefs */ + typedef RemoveIsolatedByDirectionFilter Self; + typedef ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(RemoveIsolatedByDirectionFilter,ModulusAndDirectionImageToImageFilter); + + /** typedef of the computing filter (this allows us to derive from ModulusAndDirectionToImageFilter as well as + using the BinaryFunctorNeighBorhoodImageFilter, which is appropriate here */ + typedef Functor::RemoveIsolatedByDirectionFunctor< + typename itk::ConstNeighborhoodIterator<TInputModulus>, + typename itk::ConstNeighborhoodIterator<TInputDirection>, + typename TOutputImage::PixelType> FunctorType; + typedef otb::BinaryFunctorNeighborhoodImageFilter<TInputModulus, TInputDirection,TOutputImage,FunctorType> ComputingFilterType; + +protected: + /** Constructor */ + RemoveIsolatedByDirectionFilter(){}; + /** Destructor */ + virtual ~RemoveIsolatedByDirectionFilter() {}; + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os,indent); + }; + /** Main computation method */ + virtual void GenerateData(void) + { + typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); + filter->SetInput1(this->GetInput()); + filter->SetInput2(this->GetInputDirection()); + filter->GraftOutput(this->GetOutput()); + filter->Update(); + this->GraftOutput(filter->GetOutput()); + } + +private: + RemoveIsolatedByDirectionFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +}// End namespace otb +#endif diff --git a/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.h b/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..de8c286ea6e3bd4ed14828d392be924d36fb9929 --- /dev/null +++ b/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.h @@ -0,0 +1,119 @@ +/*========================================================================= + +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 _otbRemoveWrongDirectionFilter_h +#define _otbRemoveWrongDirectionFilter_h + +#include "otbModulusAndDirectionImageToImageFilter.h" +#include "itkBinaryFunctorImageFilter.h" + +#ifndef M_PI +#define M_PI vcl_acos(-1.0) +#endif + +namespace otb +{ +namespace Functor + { + /** \class RemoveWrongDirectionFunctor + * \brief This functor is used by the RemoveWrongDirectionFilter + * \sa RemoveWrongDirectionFilter + * \ingroup Functor + */ + template <class TInput1, class TInput2, class TOutput> + class RemoveWrongDirectionFunctor + { + public: + RemoveWrongDirectionFunctor() {}; + ~RemoveWrongDirectionFunctor() {}; + inline TOutput operator()(const TInput1 &A, const TInput2 &B) + { + if(B < M_PI/8) + { + return 0; + } + else + { + return A; + } + } + }; + } +/** \class RemoveWrongDirectionFilter + * \brief This filter removes (sets to null intensity) pixels with wrong direction. + * + * This filter is part of the road extraction framework. By using the Spectral Angle filter, + * we can assume that the direction of a road on our scalar product image is positive (greater than \$f \pi/8 \$f). + * Therefore in the input modulus and direction images, pixels whose direction is lower than this threshold are supressed + * (in fact, their intensity is set to 0). + * + * \sa NeighborhoodScalarProductFilter + * \ingroup Streamed + * \ingroup Threaded + */ +template <class TInputModulus, class TInputDirection, class TOutputImage> +class ITK_EXPORT RemoveWrongDirectionFilter + : public ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> +{ + public: + /** Standard typedefs */ + typedef RemoveWrongDirectionFilter Self; + typedef ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(RemoveWrongDirectionFilter,ModulusAndDirectionImageToImageFilter); + + /** typedef of the computing filter (this allows us to derive from ModulusAndDirectionToImageFilter as well as + using the BinaryFunctorImageFilter, which is appropriate here */ + typedef Functor::RemoveWrongDirectionFunctor< + typename TInputModulus::PixelType, + typename TInputDirection::PixelType, + typename TOutputImage::PixelType> FunctorType; + typedef itk::BinaryFunctorImageFilter<TInputModulus, TInputDirection,TOutputImage,FunctorType> ComputingFilterType; + +protected: + /** Constructor */ + RemoveWrongDirectionFilter(){}; + /** Destructor */ + virtual ~RemoveWrongDirectionFilter() {}; + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const + { + Superclass::PrintSelf(os,indent); + }; + /** Main computation method */ + virtual void GenerateData(void) + { + typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); + filter->SetInput1(this->GetInput()); + filter->SetInput2(this->GetInputDirection()); + filter->GraftOutput(this->GetOutput()); + filter->Update(); + this->GraftOutput(filter->GetOutput()); + } + +private: + RemoveWrongDirectionFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +}// End namespace otb +#endif diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 0e0c0ab189db95250095b20d23812368a36eae34..9fa19168b92c647c15e9e7739bca2b533c8ecdbe 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -499,12 +499,58 @@ ADD_TEST(feTvNeighborhoodScalarProductFilter ${FEATUREEXTRACTION_TESTS} ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr ${TEMP}/feTvNeigborhoodScalarProductDirectionOutput.hdr otbNeighborhoodScalarProductFilter - ${INPUTDATA}/Line.png + ${INPUTDATA}/InputForRoadDetection.tif ${TEMP}/feTvNeigborhoodScalarProductModulusOutput.hdr ${TEMP}/feTvNeigborhoodScalarProductDirectionOutput.hdr 1.0 ) +# ------- otb::RemoveIsolatedByDirectionFilter ------------- + +ADD_TEST(feTuRemoveIsolatedByDirectionFilterNew ${FEATUREEXTRACTION_TESTS} + otbRemoveIsolatedByDirectionFilterNew) + +ADD_TEST(feTvRemoveIsolatedByDirectionFilter ${FEATUREEXTRACTION_TESTS} + --compare-image ${EPSILON} + ${BASELINE}/feTvRemoveIsolatedByDirectionOutput.hdr + ${TEMP}/feTvRemoveIsolatedByDirectionOutput.hdr + otbRemoveIsolatedByDirectionFilter + ${BASELINE}/feTvNeigborhoodScalarProductModulusOutput.hdr + ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr + ${TEMP}/feTvRemoveIsolatedByDirectionOutput.hdr + ) + +# ------- otb::RemoveWrongDirectionFilter ------------- + +ADD_TEST(feTuRemoveWrongDirectionFilterNew ${FEATUREEXTRACTION_TESTS} + otbRemoveWrongDirectionFilterNew) + +ADD_TEST(feTvRemoveWrongDirectionFilter ${FEATUREEXTRACTION_TESTS} + --compare-image ${EPSILON} + ${BASELINE}/feTvRemoveWrongDirectionOutput.hdr + ${TEMP}/feTvRemoveWrongDirectionOutput.hdr + otbRemoveWrongDirectionFilter + ${BASELINE}/feTvNeigborhoodScalarProductModulusOutput.hdr + ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr + ${TEMP}/feTvRemoveWrongDirectionOutput.hdr + ) + +# ------- otb::NonMaxRemovalByDirectionFilter ------------- + +ADD_TEST(feTuNonMaxRemovalByDirectionFilterNew ${FEATUREEXTRACTION_TESTS} + otbNonMaxRemovalByDirectionFilterNew) + +ADD_TEST(feTvNonMaxRemovalByDirectionFilter ${FEATUREEXTRACTION_TESTS} + --compare-image ${EPSILON} + ${BASELINE}/feTvNonMaxRemovalByDirectionOutput.hdr + ${TEMP}/feTvNonMaxRemovalByDirectionOutput.hdr + otbNonMaxRemovalByDirectionFilter + ${BASELINE}/feTvNeigborhoodScalarProductModulusOutput.hdr + ${BASELINE}/feTvNeigborhoodScalarProductDirectionOutput.hdr + ${TEMP}/feTvNonMaxRemovalByDirectionOutput.hdr + ) + + # A enrichir SET(BasicFeatureExtraction_SRCS otbAlignImageToPath.cxx @@ -562,6 +608,12 @@ otbImageToEdgePathFilter.cxx otbModulusAndDirectionImageFiltersNew.cxx otbNeighborhoodScalarProductFilterNew.cxx otbNeighborhoodScalarProductFilter.cxx +otbRemoveIsolatedByDirectionFilterNew.cxx +otbRemoveIsolatedByDirectionFilter.cxx +otbRemoveWrongDirectionFilterNew.cxx +otbRemoveWrongDirectionFilter.cxx +otbNonMaxRemovalByDirectionFilterNew.cxx +otbNonMaxRemovalByDirectionFilter.cxx ) diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx index 53204d5282ce7951e40d30087699f0d0454834e5..36495876ae3cb12665e5393475d107377ad6e54a 100755 --- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx +++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx @@ -82,4 +82,10 @@ REGISTER_TEST(otbImageToEdgePathFilter); REGISTER_TEST(otbModulusAndDirectionImageFiltersNew); REGISTER_TEST(otbNeighborhoodScalarProductFilterNew); REGISTER_TEST(otbNeighborhoodScalarProductFilter); +REGISTER_TEST(otbRemoveIsolatedByDirectionFilterNew); +REGISTER_TEST(otbRemoveIsolatedByDirectionFilter); +REGISTER_TEST(otbRemoveWrongDirectionFilterNew); +REGISTER_TEST(otbRemoveWrongDirectionFilter); +REGISTER_TEST(otbNonMaxRemovalByDirectionFilterNew); +REGISTER_TEST(otbNonMaxRemovalByDirectionFilter); } diff --git a/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.cxx b/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..823ac16e1fd6571bdcc745049ae36f7a57e9f85d --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilter.cxx @@ -0,0 +1,62 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" +#include "otbNonMaxRemovalByDirectionFilter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbNonMaxRemovalByDirectionFilter(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::NonMaxRemovalByDirectionFilter<ImageType,ImageType,ImageType> NonMaxRemovalByDirectionFilterType; + + // Instantiating object + ReaderType::Pointer modReader = ReaderType::New(); + ReaderType::Pointer dirReader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + modReader->SetFileName(argv[1]); + dirReader->SetFileName(argv[2]); + writer->SetFileName(argv[3]); + NonMaxRemovalByDirectionFilterType::Pointer filter = NonMaxRemovalByDirectionFilterType::New(); + filter->SetInput(modReader->GetOutput()); + filter->SetInputDirection(dirReader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); +} + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilterNew.cxx b/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..39b0f7e52483fb1f09b4545ef0ffa5c3ed62aaf2 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbNonMaxRemovalByDirectionFilterNew.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" + +#include "otbNonMaxRemovalByDirectionFilter.h" +#include "otbImage.h" + +int otbNonMaxRemovalByDirectionFilterNew(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::NonMaxRemovalByDirectionFilter<ImageType,ImageType,ImageType> NonMaxRemovalByDirectionFilterType; + + // Instantiating object + NonMaxRemovalByDirectionFilterType::Pointer object = NonMaxRemovalByDirectionFilterType::New(); + } + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.cxx b/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d465203f94812947263c47059227def80018570b --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilter.cxx @@ -0,0 +1,62 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" +#include "otbRemoveIsolatedByDirectionFilter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbRemoveIsolatedByDirectionFilter(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::RemoveIsolatedByDirectionFilter<ImageType,ImageType,ImageType> RemoveIsolatedByDirectionFilterType; + + // Instantiating object + ReaderType::Pointer modReader = ReaderType::New(); + ReaderType::Pointer dirReader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + modReader->SetFileName(argv[1]); + dirReader->SetFileName(argv[2]); + writer->SetFileName(argv[3]); + RemoveIsolatedByDirectionFilterType::Pointer filter = RemoveIsolatedByDirectionFilterType::New(); + filter->SetInput(modReader->GetOutput()); + filter->SetInputDirection(dirReader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); +} + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilterNew.cxx b/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..510c20011607b20d830de50785c5e8b62a3c82f7 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbRemoveIsolatedByDirectionFilterNew.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" + +#include "otbRemoveIsolatedByDirectionFilter.h" +#include "otbImage.h" + +int otbRemoveIsolatedByDirectionFilterNew(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::RemoveIsolatedByDirectionFilter<ImageType,ImageType,ImageType> RemoveIsolatedByDirectionFilterType; + + // Instantiating object + RemoveIsolatedByDirectionFilterType::Pointer object = RemoveIsolatedByDirectionFilterType::New(); + } + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.cxx b/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f9360c35770ee3701fc30f2e95f17e071bbc3bc9 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilter.cxx @@ -0,0 +1,62 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" +#include "otbRemoveWrongDirectionFilter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbRemoveWrongDirectionFilter(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::RemoveWrongDirectionFilter<ImageType,ImageType,ImageType> RemoveWrongDirectionFilterType; + + // Instantiating object + ReaderType::Pointer modReader = ReaderType::New(); + ReaderType::Pointer dirReader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + modReader->SetFileName(argv[1]); + dirReader->SetFileName(argv[2]); + writer->SetFileName(argv[3]); + RemoveWrongDirectionFilterType::Pointer filter = RemoveWrongDirectionFilterType::New(); + filter->SetInput(modReader->GetOutput()); + filter->SetInputDirection(dirReader->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); +} + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilterNew.cxx b/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilterNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c6c0f67834f5bbcd77384045b630b1bd8b2da781 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbRemoveWrongDirectionFilterNew.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" + +#include "otbRemoveWrongDirectionFilter.h" +#include "otbImage.h" + +int otbRemoveWrongDirectionFilterNew(int argc, char * argv[]) +{ + try + { + const unsigned int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::RemoveWrongDirectionFilter<ImageType,ImageType,ImageType> RemoveWrongDirectionFilterType; + + // Instantiating object + RemoveWrongDirectionFilterType::Pointer object = RemoveWrongDirectionFilterType::New(); + } + + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + + catch( ... ) + { + std::cout << "Unknown exception thrown !" << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +}