diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.h b/Code/FeatureExtraction/otbFlusserPathFunction.h index 17e94fd2eee49b88068b9d3d311dad70b923649f..b4cb552386aadd911c53147aceb84dcada981cd1 100644 --- a/Code/FeatureExtraction/otbFlusserPathFunction.h +++ b/Code/FeatureExtraction/otbFlusserPathFunction.h @@ -6,7 +6,7 @@ Date : 24 mars 2006 Version : Role : Flusser's invariant Class of path - $Id:$ + $Id$ =========================================================================*/ #ifndef _otbFlusserPathFunction_h @@ -59,7 +59,7 @@ class ITK_EXPORT FlusserPathFunction : public: /** Standard class typedefs. */ typedef FlusserPathFunction Self; - typedef RealMomentPathFunction< TInputImage,TInputPath TOutput> Superclass; + typedef RealMomentPathFunction<TInputImage,TInputPath, TOutput> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -70,7 +70,7 @@ public: itkNewMacro(Self); /** InputImageType typedef support. */ - typedef TInput InputType; + typedef typename Superclass::ImageType ImageType; typedef typename Superclass::IndexType IndexType; typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; @@ -82,16 +82,12 @@ public: typedef itk::VectorContainer< unsigned,VertexType > VertexListType; typedef typename VertexListType::ConstPointer VertexListPointer; - typedef TOutput RealType; - typedef typename std::complex<RealType> ComplexType; + typedef typename Superclass::RealType RealType; - /** Dimension of the underlying image. */ - itkStaticConstMacro(ImageDimension, unsigned int, - InputType::ImageDimension); + /** Evaluate the function at non-integer positions */ virtual RealType Evaluate( const PathType& path) const; - /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ itkSetMacro(Number,short); @@ -112,7 +108,7 @@ private: } // namespace otb #ifndef OTB_MANUAL_INSTANTIATION -#include "otbFlusserImageFunction.txx" +#include "otbFlusserPathFunction.txx" #endif #endif diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.txx b/Code/FeatureExtraction/otbFlusserPathFunction.txx index 1f3411e1b0d728cda631042f270aa8f8fb51f927..5bdd47506e000271f1ed88f94d87d0245a252cd9 100644 --- a/Code/FeatureExtraction/otbFlusserPathFunction.txx +++ b/Code/FeatureExtraction/otbFlusserPathFunction.txx @@ -49,12 +49,14 @@ typename FlusserPathFunction<TInputImage,TInputPath, TOutput>::RealType FlusserPathFunction<TInputImage,TInputPath, TOutput > ::Evaluate( const PathType& path) const { - typename InputType::SizeType ImageSize; + typedef ComplexMomentPathFunction<ImageType,PathType> FunctionType; + typedef typename FunctionType::ComplexType ComplexType; + + RealType FlusserValue; ComplexType FlusserValueComplex; - typedef otb::ComplexMomentImageFunction<InputType,ComplexType> CMType; - typename CMType::Pointer function =CMType::New(); + typename FunctionType::Pointer function =FunctionType::New(); if( !this->GetInputImage() ) { diff --git a/Code/FeatureExtraction/otbHuPathFunction.txx b/Code/FeatureExtraction/otbHuPathFunction.txx index 0d5c489148e90e55a1afe446a5cee2211b1c5307..2ef8a7dddf588a91f58d5acc980b4794773eaa3c 100644 --- a/Code/FeatureExtraction/otbHuPathFunction.txx +++ b/Code/FeatureExtraction/otbHuPathFunction.txx @@ -48,11 +48,11 @@ typename HuPathFunction<TInputImage,TInputPath, TOutput >::RealType HuPathFunction<TInputImage,TInputPath, TOutput > ::Evaluate( const PathType& path) const { - RealType HuValue; typedef ComplexMomentPathFunction<ImageType,PathType> FunctionType; typedef typename FunctionType::ComplexType ComplexType; + RealType HuValue; ComplexType HuValueComplex; typename FunctionType::Pointer function =FunctionType::New(); diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index cf4307fe32e89d2686de4d6f67d80e57541bcd60..ac1ca76f41b4bbab9772bb6b238f47af88311c08 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -67,12 +67,23 @@ ADD_TEST(feTuComplexMomentPathNew ${FEATUREEXTRACTION_TESTS} otbComplexMomentPathNew) ADD_TEST(feTuComplexMomentPath ${FEATUREEXTRACTION_TESTS} - otbComplexMomentPath) + otbComplexMomentPath + ${INPUTDATA}/TeteAToto.png 1 1) + +ADD_TEST(feTuHuPathNew ${FEATUREEXTRACTION_TESTS} + otbHuPathNew) ADD_TEST(feTuHuPath ${FEATUREEXTRACTION_TESTS} otbHuPath ${INPUTDATA}/TeteAToto.png) +ADD_TEST(feTuFlusserPathNew ${FEATUREEXTRACTION_TESTS} + otbFlusserPathNew) + +ADD_TEST(feTuFlusserPath ${FEATUREEXTRACTION_TESTS} + otbFlusserPath + ${INPUTDATA}/TeteAToto.png) + ADD_TEST(feTuTouziNew ${FEATUREEXTRACTION_TESTS} otbTouziEdgeDetectorNew) @@ -137,7 +148,10 @@ otbHuImage.cxx otbFlusserImage.cxx otbComplexMomentPathNew.cxx otbComplexMomentPath.cxx +otbHuPathNew.cxx otbHuPath.cxx +otbFlusserPathNew.cxx +otbFlusserPath.cxx otbTouziEdgeDetectorNew.cxx otbTouziEdgeDetector.cxx otbTouziEdgeDetectorDirection.cxx diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx index ed828674fc28512a5c6987f959c30c9b248d4fad..72d8209717248a8762ea382d51c24bf7ab4e979d 100755 --- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx +++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx @@ -20,7 +20,10 @@ REGISTER_TEST(otbHuImage); REGISTER_TEST(otbFlusserImage); REGISTER_TEST(otbComplexMomentPathNew); REGISTER_TEST(otbComplexMomentPath); +REGISTER_TEST(otbHuPathNew); REGISTER_TEST(otbHuPath); +REGISTER_TEST(otbFlusserPathNew); +REGISTER_TEST(otbFlusserPath); REGISTER_TEST(otbTouziEdgeDetectorNew); REGISTER_TEST(otbTouziEdgeDetector); REGISTER_TEST(otbTouziEdgeDetectorDirection); diff --git a/Testing/Code/FeatureExtraction/otbFlusserPath.cxx b/Testing/Code/FeatureExtraction/otbFlusserPath.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e6a29c005bb1dd420bd6ae1884463d9f345d9bb6 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbFlusserPath.cxx @@ -0,0 +1,95 @@ +/*========================================================================= + + Programme : OTB (ORFEO ToolBox) + Auteurs : CS - P.Imbo + Language : C++ + Date : 24 mars 2006 + Version : + Role : + $Id:$ + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include "itkImage.h" + +#include "otbImageFileReader.h" +#include "otbFlusserPathFunction.h" +#include "itkPolyLineParametricPath.h" + +int otbFlusserPath( int argc, char ** argv ) +{ + try + { + const char * inputFilename = argv[1]; + unsigned int Number; + + typedef unsigned char InputPixelType; + const unsigned int Dimension = 2; + + typedef itk::Image< InputPixelType, Dimension > InputImageType; + typedef InputImageType::PointType ImagePointType; + typedef otb::ImageFileReader< InputImageType > ReaderType; + typedef itk::PolyLineParametricPath< Dimension > PathType; + typedef otb::FlusserPathFunction<InputImageType,PathType> FunctionType; + typedef FunctionType::RealType RealType; + + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName( inputFilename ); + reader->Update(); + + InputImageType::ConstPointer image = reader->GetOutput(); + + // Dessiner un carré: + ImagePointType pos; + PathType::ContinuousIndexType cindex; + PathType::Pointer pathElt = PathType::New(); + + pathElt->Initialize(); + + pos[0]=30; + pos[1]=30; + image->TransformPhysicalPointToContinuousIndex(pos,cindex); + pathElt->AddVertex(cindex); + pos[0]= 30; + pos[1]=130; + image->TransformPhysicalPointToContinuousIndex(pos,cindex); + pathElt->AddVertex(cindex); + pos[0]=130; + pos[1]=130; + image->TransformPhysicalPointToContinuousIndex(pos,cindex); + pathElt->AddVertex(cindex); + pos[0]=130; + pos[1]= 30; + image->TransformPhysicalPointToContinuousIndex(pos,cindex); + pathElt->AddVertex(cindex); + + FunctionType::Pointer function =FunctionType::New(); + function->SetInputImage( image ); + + RealType Result; + + for (Number = 1 ;Number<12;Number++) + { + function->SetNumber(Number); + Result = function->Evaluate( *pathElt ); + std::cout << "Flusser("<<Number<<") = "<< Result <<std::endl; + } + } + 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; + } + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/FeatureExtraction/otbFlusserPathNew.cxx b/Testing/Code/FeatureExtraction/otbFlusserPathNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1545780d49cfb459ac9ffdb99e59664ae5fbcfd6 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbFlusserPathNew.cxx @@ -0,0 +1,54 @@ +/*========================================================================= + + Programme : OTB (ORFEO ToolBox) + Auteurs : CS - P.Imbo + Language : C++ + Date : 24 mars 2006 + Version : + Role : + $Id:$ + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include "itkImage.h" + +#include "otbFlusserPathFunction.h" +#include "itkPolyLineParametricPath.h" + +int otbFlusserPathNew( int argc, char ** argv ) +{ + try + { + const char * inputFilename = argv[1]; + unsigned int Number; + + typedef unsigned char InputPixelType; + const unsigned int Dimension = 2; + + typedef itk::Image< InputPixelType, Dimension > InputImageType; + typedef itk::PolyLineParametricPath< Dimension > PathType; + typedef otb::FlusserPathFunction<InputImageType,PathType> FunctionType; + typedef FunctionType::RealType RealType; + + + FunctionType::Pointer function =FunctionType::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; + } + return EXIT_SUCCESS; +} + diff --git a/Testing/Code/FeatureExtraction/otbHuPath.cxx b/Testing/Code/FeatureExtraction/otbHuPath.cxx index 89858f4618674de20e2cd2fa3c9330a99d491aab..2edea23e502c6bd566b089e7c642aad3986c1058 100644 --- a/Testing/Code/FeatureExtraction/otbHuPath.cxx +++ b/Testing/Code/FeatureExtraction/otbHuPath.cxx @@ -6,7 +6,7 @@ Date : 24 mars 2006 Version : Role : - $Id:$ + $Id$ =========================================================================*/ #if defined(_MSC_VER) @@ -72,15 +72,12 @@ int otbHuPath( int argc, char ** argv ) RealType Result; - for (Number = 1 ;Number<10;Number++) + for (Number = 1 ;Number<8;Number++) { function->SetNumber(Number); Result = function->Evaluate( *pathElt ); std::cout << "Hu("<<Number<<") = "<< Result <<std::endl; } -#if 0 - -#endif } catch( itk::ExceptionObject & err ) { diff --git a/Testing/Code/FeatureExtraction/otbHuPathNew.cxx b/Testing/Code/FeatureExtraction/otbHuPathNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b7cda07f80cda5122fa592af6a3117adf429fa73 --- /dev/null +++ b/Testing/Code/FeatureExtraction/otbHuPathNew.cxx @@ -0,0 +1,54 @@ +/*========================================================================= + + Programme : OTB (ORFEO ToolBox) + Auteurs : CS - P.Imbo + Language : C++ + Date : 24 mars 2006 + Version : + Role : + $Id:$ + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include "itkImage.h" + +#include "otbHuPathFunction.h" +#include "itkPolyLineParametricPath.h" + +int otbHuPathNew( int argc, char ** argv ) +{ + try + { + const char * inputFilename = argv[1]; + unsigned int Number; + + typedef unsigned char InputPixelType; + const unsigned int Dimension = 2; + + typedef itk::Image< InputPixelType, Dimension > InputImageType; + typedef itk::PolyLineParametricPath< Dimension > PathType; + typedef otb::HuPathFunction<InputImageType,PathType> FunctionType; + typedef FunctionType::RealType RealType; + + + FunctionType::Pointer function =FunctionType::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; + } + return EXIT_SUCCESS; +} +