diff --git a/Code/FeatureExtraction/otbComplexMomentImageFunction.h b/Code/FeatureExtraction/otbComplexMomentImageFunction.h index 30967cb947093fdc4fd40574d839aff3681b3df8..662e4b6d9ccc5d0806ec8c1c8f33035d3c361230 100644 --- a/Code/FeatureExtraction/otbComplexMomentImageFunction.h +++ b/Code/FeatureExtraction/otbComplexMomentImageFunction.h @@ -46,15 +46,16 @@ namespace otb * \ingroup ImageFunctions */ template < class TInput, - class TOutput = std::complex<double >, + class TOutput = std::complex<double>, + class TPrecision = double, class TCoordRep = float > class ITK_EXPORT ComplexMomentImageFunction : - public GeometricMomentImageFunction<TInput, TOutput,TCoordRep> + public GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep> { public: /** Standard class typedefs. */ typedef ComplexMomentImageFunction Self; - typedef GeometricMomentImageFunction<TInput, TOutput,TCoordRep> Superclass; + typedef GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -70,8 +71,13 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; - typedef TOutput ComplexType; + typedef typename Superclass::OutputType ComplexType; + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; + + /** ComplexType for calculation precision */ + typedef std::complex<PrecisionType> ComplexPrecisionType; /** Evalulate the function at specified index */ virtual ComplexType EvaluateAtIndex( const IndexType& index ) const; diff --git a/Code/FeatureExtraction/otbComplexMomentImageFunction.txx b/Code/FeatureExtraction/otbComplexMomentImageFunction.txx index b1469cd231cb8e8dfb49f7a776efade9e3750387..c5e570fb721dbe0036c8975c1479101172fe0a86 100644 --- a/Code/FeatureExtraction/otbComplexMomentImageFunction.txx +++ b/Code/FeatureExtraction/otbComplexMomentImageFunction.txx @@ -31,8 +31,8 @@ namespace otb /** * Constructor */ -template < class TInput, class TOutput, class TCoordRep> -ComplexMomentImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::ComplexMomentImageFunction() { m_P = 0; @@ -42,9 +42,9 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep> /** * */ -template < class TInput, class TOutput, class TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> void -ComplexMomentImageFunction<TInput,TOutput,TCoordRep> +ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -53,15 +53,15 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep> } -template < class TInput, class TOutput, class TCoordRep> -typename ComplexMomentImageFunction<TInput,TOutput,TCoordRep>::ComplexType -ComplexMomentImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +typename ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep>::ComplexType +ComplexMomentImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::EvaluateAtIndex(const IndexType& index) const { typename TInput::SizeType ImageSize; - ComplexType Sum; - ComplexType ValP; - ComplexType ValQ; + ComplexPrecisionType Sum; + ComplexPrecisionType ValP; + ComplexPrecisionType ValQ; IndexType IndexValue; IndexType indexPos = index; typename TInput::SizeType kernelSize; @@ -69,7 +69,7 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep> if( !this->GetInputImage() ) { otbMsgDevMacro( << "Pb with GetInputImage" ); - return ( std::complex<float>( itk::NumericTraits<float>::max(), itk::NumericTraits<float>::max() ) ); + return ( static_cast<ComplexType>( itk::NumericTraits<PrecisionType>::max(), itk::NumericTraits<PrecisionType>::max() ) ); } if(this->GetNeighborhoodRadius()<0) @@ -93,28 +93,28 @@ ComplexMomentImageFunction<TInput,TOutput,TCoordRep> // Set the iterator at the desired location it.SetLocation(indexPos); - Sum = std::complex<float>(0.0,0.0); + Sum = ComplexPrecisionType(0.0,0.0); const unsigned int size = it.Size(); for (unsigned int i = 0; i < size; ++i) { IndexValue = it.GetIndex(i); - ValP = std::complex<float>(1.0,0.0); - ValQ = std::complex<float>(1.0,0.0); + ValP = ComplexPrecisionType(1.0,0.0); + ValQ = ComplexPrecisionType(1.0,0.0); unsigned int p = m_P; while(p>0) { - ValP *= std::complex<float>(IndexValue[0], IndexValue[1]); + ValP *= ComplexPrecisionType(IndexValue[0], IndexValue[1]); --p; } unsigned int q = m_Q; while(q>0) { - ValQ *= std::complex<float>(IndexValue[0], -IndexValue[1]); + ValQ *= ComplexPrecisionType(IndexValue[0], -IndexValue[1]); --q; } - Sum += ( ValP * ValQ * std::complex<float>(static_cast<float>(it.GetPixel(i)),0.0) ); + Sum += ( ValP * ValQ * ComplexPrecisionType(static_cast<PrecisionType>(it.GetPixel(i)),0.0) ); } diff --git a/Code/FeatureExtraction/otbComplexMomentPathFunction.h b/Code/FeatureExtraction/otbComplexMomentPathFunction.h index 32bb336efebbbc52ff51b53f4d2a0f45d7c5a68a..8218df2703905f65e076b302ab5976178ade8ac0 100644 --- a/Code/FeatureExtraction/otbComplexMomentPathFunction.h +++ b/Code/FeatureExtraction/otbComplexMomentPathFunction.h @@ -46,15 +46,17 @@ namespace otb * \ingroup ImageFunctions */ template < class TInputPath, - class TOutput = std::complex<double> > + class TOutput = std::complex<double>, + class TPrecision = double> class ITK_EXPORT ComplexMomentPathFunction : public GeometricMomentPathFunction< TInputPath, - TOutput > + TOutput, + TPrecision > { public: /** Standard class typedefs. */ typedef ComplexMomentPathFunction Self; - typedef GeometricMomentPathFunction<TInputPath, TOutput > Superclass; + typedef GeometricMomentPathFunction<TInputPath, TOutput, TPrecision> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -72,11 +74,18 @@ public: typedef itk::VectorContainer< unsigned,VertexType > VertexListType; typedef typename VertexListType::ConstPointer VertexListPointer; -// typedef typename Superclass::OutputType ComplexType; - typedef std::complex<double> ComplexType; - typedef TOutput OutputType; - typedef float RealType; + /** Complex Type */ + typedef typename Superclass::OutputType ComplexType; + typedef typename Superclass::OutputType OutputType; + + typedef double RealType; + + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; + + /** ComplexType for calculation precision */ + typedef std::complex<PrecisionType> ComplexPrecisionType; /** Evalulate the function */ virtual OutputType Evaluate(const PathType& path) const; diff --git a/Code/FeatureExtraction/otbComplexMomentPathFunction.txx b/Code/FeatureExtraction/otbComplexMomentPathFunction.txx index 62bab30ed33c5257df78d3ef93b681851ccc45c1..968932a4a5c462924e89209fc3645575d816728a 100644 --- a/Code/FeatureExtraction/otbComplexMomentPathFunction.txx +++ b/Code/FeatureExtraction/otbComplexMomentPathFunction.txx @@ -31,8 +31,8 @@ namespace otb /** * Constructor */ -template < class TInputPath, class TOutput> -ComplexMomentPathFunction<TInputPath,TOutput> +template < class TInputPath, class TOutput, class TPrecision> +ComplexMomentPathFunction<TInputPath,TOutput,TPrecision> ::ComplexMomentPathFunction() { m_P = 0; @@ -43,9 +43,9 @@ ComplexMomentPathFunction<TInputPath,TOutput> /** * */ -template < class TInputPath, class TOutput> +template < class TInputPath, class TOutput, class TPrecision> void -ComplexMomentPathFunction<TInputPath,TOutput> +ComplexMomentPathFunction<TInputPath,TOutput,TPrecision> ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -54,44 +54,42 @@ ComplexMomentPathFunction<TInputPath,TOutput> } -template < class TInputPath, class TOutput> -typename ComplexMomentPathFunction<TInputPath,TOutput>::ComplexType -ComplexMomentPathFunction<TInputPath,TOutput> +template < class TInputPath, class TOutput, class TPrecision> +typename ComplexMomentPathFunction<TInputPath,TOutput,TPrecision>::ComplexType +ComplexMomentPathFunction<TInputPath,TOutput,TPrecision> ::EvaluateComplexMomentAtIndex(VertexType index) const { - ComplexType ValP; - ComplexType ValQ; - ComplexType Result; - double PixelValue = 1.0; + ComplexPrecisionType ValP; + ComplexPrecisionType ValQ; + ComplexPrecisionType Result; + PrecisionType PixelValue(1.0); - ValP = std::complex<double>(1.0,0.0); - ValQ = std::complex<double>(1.0,0.0); + ValP = ComplexPrecisionType(1.0,0.0); + ValQ = ComplexPrecisionType(1.0,0.0); unsigned int p = m_P; while(p>0) { - ValP *= std::complex<double>(index[0], index[1]); + ValP *= ComplexPrecisionType(index[0], index[1]); --p; } unsigned int q = m_Q; while(q>0) { - ValQ *= std::complex<double>(index[0], -index[1]); + ValQ *= ComplexPrecisionType(index[0], -index[1]); --q; } - Result = ValP * ValQ * std::complex<double>( static_cast<double>(PixelValue), 0.0); + Result = ValP * ValQ * ComplexPrecisionType( static_cast<PrecisionType>(PixelValue), 0.0); return ( static_cast<ComplexType>(Result) ); } -template < class TInputPath, class TOutput> +template < class TInputPath, class TOutput, class TPrecision> typename ComplexMomentPathFunction<TInputPath, - TOutput>::OutputType -ComplexMomentPathFunction<TInputPath,TOutput> + TOutput,TPrecision>::OutputType +ComplexMomentPathFunction<TInputPath,TOutput,TPrecision> ::Evaluate(const PathType& path) const { - typedef float RealType; - PathConstPointer Path; VertexListPointer vertexList; VertexType cindex; @@ -99,7 +97,6 @@ ComplexMomentPathFunction<TInputPath,TOutput> int nbPath; ComplexType Value; - Value = static_cast<ComplexType>(0.0); vertexList = path.GetVertexList(); @@ -110,14 +107,14 @@ ComplexMomentPathFunction<TInputPath,TOutput> for(int i =0 ; i<nbPath-1 ;i++) { cindex = vertexList->GetElement(i); - RealType x1 = cindex[0]; - RealType y1 = cindex[1]; + PrecisionType x1 = cindex[0]; + PrecisionType y1 = cindex[1]; cindex = vertexList->GetElement(i+1); - RealType x2 = cindex[0]; - RealType y2 = cindex[1]; + PrecisionType x2 = cindex[0]; + PrecisionType y2 = cindex[1]; - RealType Theta; - RealType Norm; + PrecisionType Theta; + PrecisionType Norm; Theta = atan2(y2-y1,x2-x1); Norm = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ); @@ -135,16 +132,16 @@ ComplexMomentPathFunction<TInputPath,TOutput> } -template < class TInputPath, class TOutput> +template < class TInputPath, class TOutput, class TPrecision> typename ComplexMomentPathFunction<TInputPath, - TOutput>::OutputType -ComplexMomentPathFunction<TInputPath,TOutput> + TOutput,TPrecision>::OutputType +ComplexMomentPathFunction<TInputPath,TOutput,TPrecision> ::Evaluate() const { if( !this->GetInputPath() ) { otbMsgDevMacro( << "Pb with GetInputPath" ); - return static_cast<OutputType>(std::complex<float>( itk::NumericTraits<float>::max(), itk::NumericTraits<float>::max() ) ); + return static_cast<OutputType>(ComplexPrecisionType( itk::NumericTraits<PrecisionType>::max(), itk::NumericTraits<PrecisionType>::max() ) ); } OutputType Result = Evaluate( *(this->GetInputPath()) ); diff --git a/Code/FeatureExtraction/otbFlusserImageFunction.h b/Code/FeatureExtraction/otbFlusserImageFunction.h index 7875863543eacc4bd334b349644dbea9d595e08f..4cad09d3fd485b193d37813274eb04a18b8775a0 100644 --- a/Code/FeatureExtraction/otbFlusserImageFunction.h +++ b/Code/FeatureExtraction/otbFlusserImageFunction.h @@ -60,15 +60,16 @@ namespace otb */ template < class TInput, - class TOutput = double, - class TCoordRep = float > + class TOutput = double, + class TPrecision = double, + class TCoordRep = float > class ITK_EXPORT FlusserImageFunction : - public RealMomentImageFunction< TInput, TOutput,TCoordRep > + public RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep > { public: /** Standard class typedefs. */ typedef FlusserImageFunction Self; - typedef RealMomentImageFunction< TInput, TOutput,TCoordRep > Superclass; + typedef RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -84,8 +85,12 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; - typedef TOutput RealType; + typedef typename Superclass::RealType RealType; typedef typename std::complex<RealType> ComplexType; + + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; + /** Dimension of the underlying image. */ itkStaticConstMacro(ImageDimension, unsigned int, diff --git a/Code/FeatureExtraction/otbFlusserImageFunction.txx b/Code/FeatureExtraction/otbFlusserImageFunction.txx index b41e05f932df0a16d94c838a001a2777e6ed95db..bbc6cc9f07b1b5eed6c23a365177d6dd50bebe7e 100644 --- a/Code/FeatureExtraction/otbFlusserImageFunction.txx +++ b/Code/FeatureExtraction/otbFlusserImageFunction.txx @@ -30,8 +30,8 @@ namespace otb /** * Constructor */ -template < class TInput, class TOutput, class TCoordRep> -FlusserImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::FlusserImageFunction() { m_MomentNumber =-1; @@ -40,9 +40,9 @@ FlusserImageFunction<TInput,TOutput,TCoordRep> /** * */ -template < class TInput, class TOutput, class TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> void -FlusserImageFunction<TInput,TOutput,TCoordRep> +FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -50,9 +50,9 @@ FlusserImageFunction<TInput,TOutput,TCoordRep> } -template < class TInput, class TOutput, class TCoordRep> -typename FlusserImageFunction<TInput,TOutput,TCoordRep>::RealType -FlusserImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +typename FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep>::RealType +FlusserImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::EvaluateAtIndex(const IndexType& index) const { diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.h b/Code/FeatureExtraction/otbFlusserPathFunction.h index 7ead22474479384af9cc1c61354127bcd9f62ae5..95f60979c4497f61a0a884ecd667e790fe786b0d 100644 --- a/Code/FeatureExtraction/otbFlusserPathFunction.h +++ b/Code/FeatureExtraction/otbFlusserPathFunction.h @@ -57,14 +57,15 @@ namespace otb */ template < class TInputPath, - class TOutput = double> + class TOutput = double, + class TPrecision = double> class ITK_EXPORT FlusserPathFunction : - public RealMomentPathFunction< TInputPath, TOutput > + public RealMomentPathFunction< TInputPath, TOutput, TPrecision > { public: /** Standard class typedefs. */ typedef FlusserPathFunction Self; - typedef RealMomentPathFunction<TInputPath, TOutput> Superclass; + typedef RealMomentPathFunction<TInputPath, TOutput, TPrecision> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -82,8 +83,9 @@ public: typedef typename VertexListType::ConstPointer VertexListPointer; typedef typename Superclass::RealType RealType; - - + + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; /** Evaluate the function at non-integer positions */ virtual RealType Evaluate( const PathType& path) const; diff --git a/Code/FeatureExtraction/otbFlusserPathFunction.txx b/Code/FeatureExtraction/otbFlusserPathFunction.txx index 731d4985bedb9759d53d100dae2026cae1615808..895d2e027302365f97f5acdb0b00d2adf3f6bb89 100644 --- a/Code/FeatureExtraction/otbFlusserPathFunction.txx +++ b/Code/FeatureExtraction/otbFlusserPathFunction.txx @@ -29,8 +29,8 @@ namespace otb /** * Constructor */ -template < class TInputPath, class TOutput> -FlusserPathFunction<TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +FlusserPathFunction<TInputPath, TOutput, TPrecision > ::FlusserPathFunction() { m_MomentNumber =-1; @@ -39,9 +39,9 @@ FlusserPathFunction<TInputPath, TOutput > /** * */ -template < class TInputPath, class TOutput> +template < class TInputPath, class TOutput, class TPrecision> void -FlusserPathFunction< TInputPath, TOutput > +FlusserPathFunction< TInputPath, TOutput, TPrecision > ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -49,9 +49,9 @@ FlusserPathFunction< TInputPath, TOutput > } -template < class TInputPath, class TOutput> -typename FlusserPathFunction<TInputPath, TOutput>::RealType -FlusserPathFunction<TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +typename FlusserPathFunction<TInputPath, TOutput, TPrecision>::RealType +FlusserPathFunction<TInputPath, TOutput, TPrecision > ::Evaluate( const PathType& path) const { typedef ComplexMomentPathFunction<PathType> FunctionType; @@ -214,15 +214,15 @@ FlusserPathFunction<TInputPath, TOutput > } -template < class TInputPath, class TOutput> -typename FlusserPathFunction<TInputPath, TOutput>::RealType -FlusserPathFunction<TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +typename FlusserPathFunction<TInputPath, TOutput, TPrecision>::RealType +FlusserPathFunction<TInputPath, TOutput, TPrecision > ::Evaluate() const { if( !this->GetInputPath() ) { otbMsgDevMacro( << "Pb with GetInputPath" ); - return static_cast<RealType>( itk::NumericTraits<float>::max()); + return static_cast<RealType>( itk::NumericTraits<PrecisionType>::max()); } RealType Result = Evaluate( *(this->GetInputPath()) ); diff --git a/Code/FeatureExtraction/otbGeometricMomentImageFunction.h b/Code/FeatureExtraction/otbGeometricMomentImageFunction.h index 3c1e1ec261d1df91d9657e1b8a451fc0d4a6aa66..237d5a321eaa852a782472fda3c7bd46a919d023 100644 --- a/Code/FeatureExtraction/otbGeometricMomentImageFunction.h +++ b/Code/FeatureExtraction/otbGeometricMomentImageFunction.h @@ -33,7 +33,8 @@ namespace otb template < class TInput, class TOutput = float, - class TCoordRep = float > + class TPrecision = double, + class TCoordRep = float > class ITK_EXPORT GeometricMomentImageFunction : public itk::ImageFunction<TInput, TOutput,TCoordRep > { @@ -55,7 +56,8 @@ public: typedef typename Superclass::PointType PointType; typedef TOutput OutputType; - + /** Type for calculation precision */ + typedef TPrecision PrecisionType; /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ diff --git a/Code/FeatureExtraction/otbGeometricMomentPathFunction.h b/Code/FeatureExtraction/otbGeometricMomentPathFunction.h index a1fcc7d20b2e61b9b9d9d703276f8b848497cb52..e0dc4d9d7ac6991ad1ea22f0e8fe9a60c67d393d 100644 --- a/Code/FeatureExtraction/otbGeometricMomentPathFunction.h +++ b/Code/FeatureExtraction/otbGeometricMomentPathFunction.h @@ -32,7 +32,8 @@ namespace otb */ template < class TInputPath, - class TOutput > + class TOutput, + class TPrecision = double> class ITK_EXPORT GeometricMomentPathFunction : public PathFunction< TInputPath, TOutput> { @@ -54,6 +55,9 @@ public: /** OutputPathType typedef support. */ typedef typename Superclass::OutputType OutputType; + /** Type for calculation precision */ + typedef TPrecision PrecisionType; + protected: GeometricMomentPathFunction() {}; diff --git a/Code/FeatureExtraction/otbHuImageFunction.h b/Code/FeatureExtraction/otbHuImageFunction.h index b5bf0e55e3869f1e32691c2c3bac602d728859c5..049ea7bd840ca588bbc9c7f5a21fb57906a5e537 100644 --- a/Code/FeatureExtraction/otbHuImageFunction.h +++ b/Code/FeatureExtraction/otbHuImageFunction.h @@ -54,15 +54,16 @@ namespace otb // public itk::ImageFunction< TInput, TOutput,TCoordRep > template < class TInput, - class TOutput = double, - class TCoordRep = float > + class TOutput = double, + class TPrecision = double, + class TCoordRep = float > class ITK_EXPORT HuImageFunction : - public RealMomentImageFunction< TInput, TOutput,TCoordRep > + public RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep > { public: /** Standard class typedefs. */ typedef HuImageFunction Self; - typedef RealMomentImageFunction< TInput, TOutput,TCoordRep > Superclass; + typedef RealMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -78,8 +79,11 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; - typedef TOutput RealType; + typedef typename Superclass::RealType RealType; typedef typename std::complex<RealType> ComplexType; + + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; /** Dimension of the underlying image. */ itkStaticConstMacro(ImageDimension, unsigned int, diff --git a/Code/FeatureExtraction/otbHuImageFunction.txx b/Code/FeatureExtraction/otbHuImageFunction.txx index 42f60aa5411dedb51c8e90452ea995882719ddbf..3ff339b9ba80a73af8c93dc95281ba055929bcb7 100644 --- a/Code/FeatureExtraction/otbHuImageFunction.txx +++ b/Code/FeatureExtraction/otbHuImageFunction.txx @@ -30,8 +30,8 @@ namespace otb /** * Constructor */ -template < class TInput, class TOutput, class TCoordRep> -HuImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +HuImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::HuImageFunction() { m_MomentNumber =-1; @@ -40,9 +40,9 @@ HuImageFunction<TInput,TOutput,TCoordRep> /** * */ -template < class TInput, class TOutput, class TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> void -HuImageFunction<TInput,TOutput,TCoordRep> +HuImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -50,9 +50,9 @@ HuImageFunction<TInput,TOutput,TCoordRep> } -template < class TInput, class TOutput, class TCoordRep> -typename HuImageFunction<TInput,TOutput,TCoordRep>::RealType -HuImageFunction<TInput,TOutput,TCoordRep> +template < class TInput, class TOutput, class TPrecision, class TCoordRep> +typename HuImageFunction<TInput,TOutput,TPrecision,TCoordRep>::RealType +HuImageFunction<TInput,TOutput,TPrecision,TCoordRep> ::EvaluateAtIndex(const IndexType& index) const { //typename InputType::SizeType ImageSize; diff --git a/Code/FeatureExtraction/otbHuPathFunction.h b/Code/FeatureExtraction/otbHuPathFunction.h index 94f2fed7437fa02d82b1e39d0f2f5f372c177037..f25044c45132ded8ea89bbb450e501ea0582bdc7 100644 --- a/Code/FeatureExtraction/otbHuPathFunction.h +++ b/Code/FeatureExtraction/otbHuPathFunction.h @@ -53,14 +53,15 @@ namespace otb */ template < class TInputPath, - class TOutput = double> + class TOutput = double, + class TPrecision = double> class ITK_EXPORT HuPathFunction : - public RealMomentPathFunction< TInputPath, TOutput > + public RealMomentPathFunction< TInputPath, TOutput, TPrecision > { public: /** Standard class typedefs. */ typedef HuPathFunction Self; - typedef RealMomentPathFunction<TInputPath, TOutput> Superclass; + typedef RealMomentPathFunction<TInputPath, TOutput, TPrecision> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -79,6 +80,9 @@ public: /** OutputType typedef support. */ typedef typename Superclass::RealType RealType; + + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; /** Evaluate the function at non-integer positions */ virtual RealType Evaluate( const PathType& path) const; diff --git a/Code/FeatureExtraction/otbHuPathFunction.txx b/Code/FeatureExtraction/otbHuPathFunction.txx index f010b4bb8879a6b30880653de90d110253e95271..7d30d36f1696c5f399672bb398501ec49bf1e5ca 100644 --- a/Code/FeatureExtraction/otbHuPathFunction.txx +++ b/Code/FeatureExtraction/otbHuPathFunction.txx @@ -30,8 +30,8 @@ namespace otb /** * Constructor */ -template < class TInputPath, class TOutput> -HuPathFunction< TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +HuPathFunction< TInputPath, TOutput, TPrecision > ::HuPathFunction() { m_MomentNumber =-1; @@ -40,9 +40,9 @@ HuPathFunction< TInputPath, TOutput > /** * */ -template < class TInputPath, class TOutput> +template < class TInputPath, class TOutput, class TPrecision> void -HuPathFunction< TInputPath, TOutput > +HuPathFunction< TInputPath, TOutput, TPrecision > ::PrintSelf(std::ostream& os, itk::Indent indent) const { this->Superclass::PrintSelf(os,indent); @@ -50,9 +50,9 @@ HuPathFunction< TInputPath, TOutput > } -template < class TInputPath, class TOutput> -typename HuPathFunction<TInputPath, TOutput >::RealType -HuPathFunction<TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +typename HuPathFunction<TInputPath, TOutput, TPrecision >::RealType +HuPathFunction<TInputPath, TOutput, TPrecision > ::Evaluate( const PathType& path) const { typedef ComplexMomentPathFunction<PathType> FunctionType; @@ -171,15 +171,15 @@ HuPathFunction<TInputPath, TOutput > } -template < class TInputPath, class TOutput> -typename HuPathFunction<TInputPath, TOutput >::RealType -HuPathFunction<TInputPath, TOutput > +template < class TInputPath, class TOutput, class TPrecision> +typename HuPathFunction<TInputPath, TOutput, TPrecision >::RealType +HuPathFunction<TInputPath, TOutput, TPrecision > ::Evaluate( ) const { if( !this->GetInputPath() ) { otbMsgDevMacro( << "Pb with GetInputPath" ); - return static_cast<RealType>( itk::NumericTraits<float>::max()); + return static_cast<RealType>( itk::NumericTraits<PrecisionType>::max()); } RealType Result = Evaluate( *(this->GetInputPath()) ); diff --git a/Code/FeatureExtraction/otbRealMomentImageFunction.h b/Code/FeatureExtraction/otbRealMomentImageFunction.h index 7dbd6e860351cd8deca9ca96695c3d558d052398..5709ac233922d2420182323d515857094791bbcf 100644 --- a/Code/FeatureExtraction/otbRealMomentImageFunction.h +++ b/Code/FeatureExtraction/otbRealMomentImageFunction.h @@ -33,14 +33,15 @@ namespace otb template < class TInput, class TOutput = float, + class TPrecision = double, class TCoordRep = float > class ITK_EXPORT RealMomentImageFunction : - public GeometricMomentImageFunction<TInput, TOutput,TCoordRep > + public GeometricMomentImageFunction<TInput, TOutput, TPrecision, TCoordRep > { public: /** Standard class typedefs. */ typedef RealMomentImageFunction Self; - typedef GeometricMomentImageFunction< TInput, TOutput,TCoordRep > Superclass; + typedef GeometricMomentImageFunction< TInput, TOutput, TPrecision, TCoordRep > Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -54,8 +55,11 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::PointType PointType; - typedef TOutput OutputType; - typedef TOutput RealType; + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; + + typedef typename Superclass::OutputType OutputType; + typedef OutputType RealType; diff --git a/Code/FeatureExtraction/otbRealMomentPathFunction.h b/Code/FeatureExtraction/otbRealMomentPathFunction.h index 6756263acc2abf176c790c2037fa5bf73239668a..b8d62d6b35a69533511d092896e9b3d0caffde93 100644 --- a/Code/FeatureExtraction/otbRealMomentPathFunction.h +++ b/Code/FeatureExtraction/otbRealMomentPathFunction.h @@ -33,14 +33,15 @@ namespace otb */ template < class TInputPath, - class TOutput = double> + class TOutput = double, + class TPrecision = double> class ITK_EXPORT RealMomentPathFunction : - public GeometricMomentPathFunction< TInputPath, TOutput> + public GeometricMomentPathFunction< TInputPath, TOutput, TPrecision> { public: /** Standard class typedefs. */ typedef RealMomentPathFunction Self; - typedef GeometricMomentPathFunction< TInputPath, TOutput> Superclass; + typedef GeometricMomentPathFunction< TInputPath, TOutput, TPrecision> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -54,6 +55,9 @@ public: typedef itk::VectorContainer< unsigned,VertexType > VertexListType; typedef typename VertexListType::ConstPointer VertexListPointer; + /** Type for calculation precision */ + typedef typename Superclass::PrecisionType PrecisionType; + /** OutputType typedef support. */ typedef typename Superclass::OutputType RealType;