diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 0ac5945088c94ea7d4057762a4617357eb122447..ff07b161071afe94c589f52df0180d261804db8f 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -166,6 +166,9 @@ ADD_TEST(feTvMultiplyByScalarImage ${FEATUREEXTRACTION_TESTS} ADD_TEST(feTuThresholdImageToPointSetTest ${FEATUREEXTRACTION_TESTS} otbThresholdImageToPointSetTest ${INPUTDATA}/TeteAToto.png) + +ADD_TEST(feTuPixelSuppressionByDirectionNew ${FEATUREEXTRACTION_TESTS} + otbPixelSuppressionByDirectionNew) #ADD_TEST(tvFEPatrick2 ${FEATUREEXTRACTION_TESTS} # --compare-image ${TOL} ${BASELINE}/otbExtractROI_cthead1_26_97_209_100.png @@ -208,6 +211,7 @@ otbAssymetricFusionOfLineDetector.cxx otbHarrisImage.cxx otbMultiplyByScalarImageTest.cxx otbThresholdImageToPointSetTest.cxx +otbPixelSuppressionByDirectionNew.cxx ) diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx index 5c0375d66e71cf6df3ee471d60f9e7fecfea6bef..f7eedf24536f58bcc8a18417c3f37a731821c488 100755 --- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx +++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx @@ -40,5 +40,5 @@ REGISTER_TEST(otbAssymetricFusionOfLineDetector); REGISTER_TEST(otbHarrisImage); REGISTER_TEST(otbMultiplyByScalarImageFilterTest); REGISTER_TEST(otbThresholdImageToPointSetTest); - +REGISTER_TEST(otbPixelSuppressionByDirectionNew); } diff --git a/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirection.cxx b/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirection.cxx new file mode 100755 index 0000000000000000000000000000000000000000..465fc41237b352c0e8673d98f40cdde75118cc65 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirection.cxx @@ -0,0 +1,96 @@ +/*========================================================================= + + Programme : OTB (ORFEO ToolBox) + Auteurs : CS - C.Ruffel + Language : C++ + Date : 14 mars 2006 + Version : + Role : Test du filtre de suppression par direction des pixels isoles + $Id$ + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#define MAIN + + +#include "itkExceptionObject.h" +#include "itkImage.h" +#include "itkImageFileWriter.h" +#include <iostream> + +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbPixelSuppressionByDirectionImageFilter.h" + +int otbPixelSuppressionByDirection( int argc, char* argv[] ) +{ + try + { + const char * inputFilename1 = argv[1]; + const char * inputFilename2 = argv[2]; + const char * outputFilename = argv[3]; + + unsigned int RadiusX((unsigned int)::atoi(argv[3])); + double AngularBeam((double)::atof(argv[4])); + + typedef double InputPixelType; + typedef double OutputPixelType; + const unsigned int Dimension = 2; + + typedef itk::Image< InputPixelType, Dimension > InputImageType1; + typedef itk::Image< OutputPixelType, Dimension > OutputImageType; + + typedef otb::ImageFileReader< InputImageType1 > ReaderType1; + typedef otb::ImageFileReader< InputImageType1 > ReaderType2; + typedef otb::ImageFileWriter< OutputImageType > WriterType; + + typedef otb::PixelSuppressionByDirection< InputImageType1, OutputImageType > FilterType; + + FilterType::Pointer filter = FilterType::New(); + + + FilterType::SizeType Radius; + Radius[0] = RadiusX; + Radius[1] = RadiusX; + + + filter->SetRadius( Radius ); + filter->SetAngularBeam( static_cast<FilterType::InputRealType>( AngularBeam )); + + + ReaderType1::Pointer reader1 = ReaderType1::New(); + ReaderType2::Pointer reader2 = ReaderType2::New(); + WriterType::Pointer writer = WriterType::New(); + + reader1->SetFileName( inputFilename1 ); + reader2->SetFileName( inputFilename2 ); + writer->SetFileName( outputFilename ); + + filter->SetInputImage( reader1->GetOutput() ); + filter->SetInputImageDirection( reader2->GetOutput() ); + writer->SetInput( filter->GetOutput() ); + + writer->Update(); + + } + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject levee !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + catch( ... ) + { + std::cout << "Exception levee inconnue !" << std::endl; + return EXIT_FAILURE; + } + // Software Guide : EndCodeSnippet + +//#endif + return EXIT_SUCCESS; +} + + diff --git a/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirectionNew.cxx b/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirectionNew.cxx new file mode 100755 index 0000000000000000000000000000000000000000..d2eac292acf39f71052eee04660f375c7db0c954 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbPixelSuppressionByDirectionNew.cxx @@ -0,0 +1,66 @@ +/*========================================================================= + + Programme : OTB (ORFEO ToolBox) + Auteurs : CS - C.Ruffel + Language : C++ + Date : 14 mars 2006 + Version : + Role : Test d'instanciation du filtre de suppression par direction des pixels isoles + $Id$ + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#define MAIN + + +#include "itkExceptionObject.h" +#include "itkImage.h" +#include "itkImageFileWriter.h" +#include <iostream> + +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbPixelSuppressionByDirectionImageFilter.h" + +int otbPixelSuppressionByDirectionNew( int argc, char* argv[] ) +{ + try + { + typedef double InputPixelType; + typedef double OutputPixelType; + const unsigned int Dimension = 2; + + typedef itk::Image< InputPixelType, Dimension > InputImageType; + typedef itk::Image< OutputPixelType, Dimension > OutputImageType; + + typedef otb::ImageFileReader< InputImageType > ReaderType1; + typedef otb::ImageFileReader< InputImageType > ReaderType2; + typedef otb::ImageFileWriter< OutputImageType > WriterType; + + typedef otb::PixelSuppressionByDirectionImageFilter< InputImageType, OutputImageType > FilterType; + + FilterType::Pointer filter = FilterType::New(); + + + } + catch( itk::ExceptionObject & err ) + { + std::cout << "Exception itk::ExceptionObject levee !" << std::endl; + std::cout << err << std::endl; + return EXIT_FAILURE; + } + catch( ... ) + { + std::cout << "Exception levee inconnue !" << std::endl; + return EXIT_FAILURE; + } + // Software Guide : EndCodeSnippet + +//#endif + return EXIT_SUCCESS; +} + +