diff --git a/Code/BasicFilters/otbLogPolarResampleImageFilter.h b/Code/BasicFilters/otbLogPolarResampleImageFilter.h index 81dc020e1855fb569766a4c785c827795694eb18..72929a37526083460505a944908efb225a05654b 100644 --- a/Code/BasicFilters/otbLogPolarResampleImageFilter.h +++ b/Code/BasicFilters/otbLogPolarResampleImageFilter.h @@ -141,7 +141,7 @@ public: /** Set the Sigma value. */ itkSetMacro(Sigma, double); /** Get the Sigma value. */ - itkGetConstReferenceMacro(Sigma, double); + itkGetConstMacro(Sigma, double); /** LogPolarResampleImageFilter produces an image which is a different size * than its input. As such, it needs to provide an implementation diff --git a/Code/FeatureExtraction/CMakeLists.txt b/Code/FeatureExtraction/CMakeLists.txt index 2b5f7fb8a0e786938296e717f36f7c8620afee58..a3593d02f483680e517941fc554f154ec5d96bd3 100755 --- a/Code/FeatureExtraction/CMakeLists.txt +++ b/Code/FeatureExtraction/CMakeLists.txt @@ -4,7 +4,7 @@ FILE(GLOB OTBFeatureExtraction_SRCS "*.cxx" ) ADD_LIBRARY(OTBFeatureExtraction ${OTBFeatureExtraction_SRCS}) -TARGET_LINK_LIBRARIES (OTBFeatureExtraction OTBCommon OTBIO ITKCommon ITKIO) +TARGET_LINK_LIBRARIES (OTBFeatureExtraction OTBCommon OTBIO ITKCommon ITKIO ITKAlgorithms) INSTALL_TARGETS(/lib/otb OTBFeatureExtraction ) INSTALL_FILES(/include/otb/FeatureExtraction "(\\.h|\\.txx)$") diff --git a/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.h b/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..c9840b4fcfff40b878bdffbc01e19da0b3f32787 --- /dev/null +++ b/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.h @@ -0,0 +1,148 @@ +/*========================================================================= + + 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 _otbForwardFourierMellinTransformImageFilter_h +#define _otbForwardFourierMellinTransformImageFilter_h + +#include "otbImage.h" +#include "otbLogPolarResampleImageFilter.h" +#include "itkLinearInterpolateImageFunction.h" +#include "itkImageToImageFilter.h" +#include "itkVnlFFTRealToComplexConjugateImageFilter.h" + +namespace otb +{ + +/** + * \class ForwardFourierMellinTransformImageFilter + * \brief Calculate the Fourier-Mellin transform over an image. + * + * This class implements a composite filter. It combines two filters : + * \begin{itemize} + * \item otb::LogPolarResampleImageFilter + * \item itk:: ... + * \end{itemize} + * + * \ingroup ImageFunctions + */ + +template < class TPixel, + class TInterpol, + unsigned int Dimension = 2 > + +class ITK_EXPORT ForwardFourierMellinTransformImageFilter : + public itk::ImageToImageFilter<Image< TPixel , Dimension >, + Image< std::complex<TPixel> , Dimension > > +{ +public: + + typedef TPixel PixelType; + typedef otb::Image< TPixel , Dimension > InputImageType; + typedef otb::Image< std::complex< TPixel > , Dimension > OutputImageType; + + /** Standard class typedefs. */ + typedef ForwardFourierMellinTransformImageFilter Self; + typedef itk::ImageToImageFilter< InputImageType, OutputImageType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + + /** Run-time type information (and related methods). */ + itkTypeMacro( ForwardFourierMellinTransformImageFilter, itk::ImageToImageFilter); + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** InputImageType typedef support. */ + typedef typename InputImageType::PixelType PixeltType; + typedef typename InputImageType::IndexType IndexType; + + typedef typename OutputImageType::PixelType ComplexType; + + /** Typedefs to describe and access Interpolator */ + typedef TInterpol InterpolatorType; + typedef typename InterpolatorType::Pointer InterpolatorPointer; + typedef typename InterpolatorType::ConstPointer InterpolatorConstPointer; + typedef typename InterpolatorType::CoordRepType CoordRepType; + typedef typename InterpolatorType::PointType PointType; + typedef typename InterpolatorType::CoordRepType CoordRepType; + + + typedef LogPolarResampleImageFilter<InputImageType,TInterpol> LogPolarResampleImageFilterType; + typedef typename LogPolarResampleImageFilterType::Pointer LogPolarResampleImageFilterPointer; + + typedef typename itk::VnlFFTRealToComplexConjugateImageFilter<PixeltType,Dimension> FourierImageFilterType; + typedef typename FourierImageFilterType::Pointer FourierImageFilterPointer; + typedef typename FourierImageFilterType::ConstPointer FourierImageFilterConstPointer; + + /** Set/Get Angular Step */ + void SetAngularStep( double angularStep ); + const double GetAngularStep( void ); + + /** Set/Get Radial Step */ + void SetRadialStep( double radialStep ); + const double GetRadialStep( void ); + + /** Set/Get Radial number of samples */ + void SetRadialNumberOfSamples( double radialNumberOfSamples ); + const double GetRadialNumberOfSamples( void ); + + /** Set/Get Angular number of samples */ + void SetAngularNumberOfSamples( double angularNumberOfSamples ); + const double GetAngularNumberOfSamples( void ); + + /** Set/Get the Sigma value for the Log-polar resampler */ + void SetSimga( double sigma ); + const double GetSigma( void ); + + /** Set/Get the IsAtCenter value for the Log-polar resampler */ + void SetIsAtCenter( bool isAtCenter ); + const bool GetIsAtCenter( void ); + + /** Set/Get the Default pixel value for the Log-polar resampler */ + void SetDefaultPixelValue( PixelType pixelValue ); +// const PixelType GetDefaultPixelValue( void ); + + /** Set/Get the Interpolator pointer for the Log-polar resampler */ + void SetInterpolator( InterpolatorPointer interpolator ); +// InterpolatorConstPointer GetInterpolator( void ); + + +protected: + ForwardFourierMellinTransformImageFilter(); + ~ForwardFourierMellinTransformImageFilter(){}; + void PrintSelf(std::ostream& os, itk::Indent indent) const; + void GenerateData(); + +private: + ForwardFourierMellinTransformImageFilter( const Self& ); //purposely not implemented + void operator=( const Self& ); //purposely not implemented + + LogPolarResampleImageFilterPointer m_LogPolarResample; + FourierImageFilterPointer m_FourierTransform; +}; + +} // namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbForwardFourierMellinTransformImageFilter.txx" +#endif + +#endif + diff --git a/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.txx b/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..31aca39b7dd45ddc57618f44e9de4cc469856415 --- /dev/null +++ b/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilter.txx @@ -0,0 +1,191 @@ +/*========================================================================= + + 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 _otbForwardFourierMellinTransformImageFilter_txx +#define _otbForwardFourierMellinTransformImageFilter_txx + +#include "otbForwardFourierMellinTransformImageFilter.h" + + +namespace otb +{ + +template < class TPixel,class TInterpol,unsigned int Dimension > +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::ForwardFourierMellinTransformImageFilter() +{ + m_LogPolarResample = LogPolarResampleImageFilterType::New(); + m_FourierTransform = FourierImageFilterType::New(); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GenerateData() +{ + m_LogPolarResample->SetInput( this->GetInput() ); + m_FourierTransform->SetInput( m_LogPolarResample->GetInput() ); + m_FourierTransform->GraftOutput( this->GetOutput() ); + m_FourierTransform->Update(); + this->GraftOutput(m_FourierTransform->GetOutput() ); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetAngularStep(double angularStep ) +{ + m_LogPolarResample->SetAngularStep(angularStep); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const double +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetAngularStep() +{ + return m_LogPolarResample->GetAngularStep(); +} + + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetRadialStep(double radialStep ) +{ + m_LogPolarResample->GetRadialStep(radialStep); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const double +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetRadialStep( ) +{ + return m_LogPolarResample->GetRadialStep(); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetAngularNumberOfSamples(double angularNumberOfSamples ) +{ + m_LogPolarResample->SetAngularNumberOfSamples(angularNumberOfSamples); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const double +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetAngularNumberOfSamples() +{ + return m_LogPolarResample->GetAngularNumberOfSamples(); +} + + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetRadialNumberOfSamples(double radialNumberOfSamples ) +{ + m_LogPolarResample->GetRadialNumberOfSamples(radialNumberOfSamples); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const double +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetRadialNumberOfSamples( ) +{ + return m_LogPolarResample->GetRadialNumberOfSamples(); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetSimga(double sigma ) +{ + m_LogPolarResample->SetSimga(sigma); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const double +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetSigma( ) +{ + return m_LogPolarResample->GetSigma(); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetIsAtCenter(bool isAtCenter) +{ + m_LogPolarResample->SetIsAtCenter(isAtCenter); +} +template < class TPixel,class TInterpol,unsigned int Dimension > +const bool +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetIsAtCenter( ) +{ + return m_LogPolarResample->GetIsAtCenter(); +} + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetDefaultPixelValue(PixelType pixelValue) +{ + m_LogPolarResample->SetDefaultPixelValue(pixelValue); +} + +/* +template < class TPixel,class TInterpol,unsigned int Dimension > +const PixelType +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetDefaultPixelValue( ) +{ + return static_cast<const PixelType>(m_LogPolarResample->GetDefaultPixelValue()); +} +*/ + +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::SetInterpolator(InterpolatorPointer interpolator ) +{ + m_LogPolarResample->SetInterpolator(interpolator); +} +/* +template < class TPixel,class TInterpol,unsigned int Dimension > +InterpolatorConstPointer +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::GetInterpolator( ) +{ + return static_cast<InterpolatorConstPointer>(m_LogPolarResample->GetInterpolator()); +} +*/ + +/** + * Standard "PrintSelf" method + */ +template < class TPixel,class TInterpol,unsigned int Dimension > +void +ForwardFourierMellinTransformImageFilter<TPixel, TInterpol, Dimension > +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf( os, indent ); + os << indent << "m_LogPolarResample : " << m_LogPolarResample.GetPointer() << std::endl; +} + + +} // end namespace otb + + +#endif diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index 5ba9203cd34c46e9b46ef5f27f3d9fc26e8e45be..2e15ed96c7bfb10bc74fc033ec5372dc658729a8 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -382,8 +382,8 @@ ADD_TEST(feTvExtractSegments ${FEATUREEXTRACTION_TESTS} # ------- otb::ForwardFourierMellinTransformImageFilter ------------- -#ADD_TEST(feTuForwardFourierMellinTransformImageFilterNew ${COMMON_TESTS} -# otbForwardFourierMellinTransformImageFilterNew) +ADD_TEST(feTuForwardFourierMellinImageFilterNew ${FEATUREEXTRACTION_TESTS} + otbFourierMellinImageFilterNew) # ----------------------------------------------------------------------- @@ -440,13 +440,14 @@ otbLocalHough.cxx otbLocalHoughDraw.cxx otbExtractSegmentsNew.cxx otbExtractSegments.cxx +otbFourierMellinImageFilterNew.cxx ) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") ADD_EXECUTABLE(otbFeatureExtractionTests otbFeatureExtractionTests.cxx ${BasicFeatureExtraction_SRCS}) -TARGET_LINK_LIBRARIES(otbFeatureExtractionTests OTBFeatureExtraction OTBCommon OTBIO gdal ITKIO ITKCommon) +TARGET_LINK_LIBRARIES(otbFeatureExtractionTests OTBFeatureExtraction OTBCommon OTBIO gdal ITKIO ITKCommon ITKAlgorithms) ENDIF( NOT OTB_DISABLE_CXX_TESTING ) diff --git a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx index 3387db67978f841e743c108a40a8c3d50963d65a..7d4ec351821c0288b944ff09a54908afb966c0e5 100755 --- a/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx +++ b/Testing/Code/FeatureExtraction/otbFeatureExtractionTests.cxx @@ -76,4 +76,5 @@ REGISTER_TEST(otbLocalHough); REGISTER_TEST(otbLocalHoughDraw); REGISTER_TEST(otbExtractSegmentsNew); REGISTER_TEST(otbExtractSegments); +REGISTER_TEST(otbFourierMellinImageFilterNew); } diff --git a/Testing/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilterNew.cxx b/Testing/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilterNew.cxx index 6c6d8d864cc0ad65efe615de3854753c54a14684..d8e229a57b8cac59650c5e4dc8a41afb3c5761f2 100644 --- a/Testing/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilterNew.cxx +++ b/Testing/Code/FeatureExtraction/otbForwardFourierMellinTransformImageFilterNew.cxx @@ -37,11 +37,12 @@ int otbForwardFourierMellinTransformImageFilterNew(int argc, char* argv[]) typedef otb::Image< PixelType, Dimension > InputImageType; typedef otb::Image< PixelType, Dimension > OutputImageType; - typedef itk::LinearInterpolateImageFunction< InputImageType, double > InterpolatorType; - typedef otb::ForwardFourierMellinTransformImageFilter<PixelType,InterpolatorType> FourierMellinTransformType; + typedef itk::LinearInterpolateImageFunction< InputImageType, double > InterpolatorType; + typedef otb::ForwardFourierMellinTransformImageFilter<PixelType, + InterpolatorType,Dimension> FourierMellinTransformType; try { - + FourierMellinTransformType::Pointer fourierMellinTransform = FourierMellinTransformType::New(); } catch( itk::ExceptionObject & err ) {