| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkFourierSeriesPath.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:35 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
DEF |
#ifndef _itkFourierSeriesPath_h |
| 19 |
DEF |
#define _itkFourierSeriesPath_h |
| 20 |
|
|
| 21 |
|
#include "itkParametricPath.h" |
| 22 |
|
#include "itkVectorContainer.h" |
| 23 |
|
#include "itkContinuousIndex.h" |
| 24 |
|
#include "itkIndex.h" |
| 25 |
|
#include "itkOffset.h" |
| 26 |
|
#include "itkVector.h" |
| 27 |
|
|
| 28 |
|
namespace itk |
| 29 |
|
{ |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
/** \class FourierSeriesPath |
| 33 |
|
* \brief Represent a closed path through ND Space by its frequency components |
| 34 |
|
* |
| 35 |
|
* This class is intended to represent closed parametric paths through an image |
| 36 |
|
* which are defined by their Fourier coeficients (frequency components). The |
| 37 |
|
* paths must be closed and defined over the interval [0,1], where the paths' |
| 38 |
|
* values at input 0 and input 1 are identical. The user can control how many |
| 39 |
|
* harmonics (how high of frequency components) are represented by a given |
| 40 |
|
* instantiation of this class. Classic applications of this class include |
| 41 |
|
* smoothing other closed paths (by finding and using only the first n harmonics |
| 42 |
|
* of their frequency components) and interpolating exact derivatives of other |
| 43 |
|
* closed paths by first converting the other paths to FourierSeriesPaths, which |
| 44 |
|
* have an exactly defined algebraic derivative. (As many harmonics as are |
| 45 |
|
* necessary to adequately approximate the original path should be used when |
| 46 |
|
* approximating derivatives.) |
| 47 |
|
* |
| 48 |
|
* \sa OrthogonallyCorrectedParametricPath |
| 49 |
|
* \sa EllipseParametricPath |
| 50 |
|
* \sa PolyLineParametricPath |
| 51 |
|
* \sa ParametricPath |
| 52 |
|
* \sa ChainCodePath |
| 53 |
|
* \sa Path |
| 54 |
|
* \sa ContinuousIndex |
| 55 |
|
* \sa Index |
| 56 |
|
* \sa Offset |
| 57 |
|
* \sa Vector |
| 58 |
|
* |
| 59 |
|
* \ingroup PathObjects |
| 60 |
|
*/ |
| 61 |
|
template <unsigned int VDimension> |
| 62 |
|
class ITK_EXPORT FourierSeriesPath : public |
| 63 |
|
ParametricPath< VDimension > |
| 64 |
|
{ |
| 65 |
|
public: |
| 66 |
|
/** Standard class typedefs. */ |
| 67 |
|
typedef FourierSeriesPath Self; |
| 68 |
|
typedef ParametricPath<VDimension> Superclass; |
| 69 |
|
typedef SmartPointer<Self> Pointer; |
| 70 |
|
typedef SmartPointer<const Self> ConstPointer; |
| 71 |
|
|
| 72 |
|
/** Run-time type information (and related methods). */ |
| 73 |
|
itkTypeMacro(FourierSeriesPath, ParametricPath); |
| 74 |
|
|
| 75 |
|
/** Input type */ |
| 76 |
|
typedef typename Superclass::InputType InputType; |
| 77 |
|
|
| 78 |
|
/** Output type */ |
| 79 |
|
typedef typename Superclass::OutputType OutputType; |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
/** Basic data-structure types used */ |
| 83 |
|
typedef ContinuousIndex<double,VDimension> ContinuousIndexType; |
| 84 |
|
typedef Index< VDimension > IndexType; |
| 85 |
|
typedef Offset< VDimension > OffsetType; |
| 86 |
|
typedef Vector<double,VDimension> VectorType; |
| 87 |
|
typedef VectorContainer<unsigned, VectorType> CoefficientsType; |
| 88 |
|
typedef typename CoefficientsType::Pointer CoefficientsPointer; |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
/** Return the location of the parametric path at the specified location. */ |
| 92 |
|
virtual OutputType Evaluate( const InputType & input ) const; |
| 93 |
|
|
| 94 |
|
/** Evaluate the first derivative of the ND output with respect to the 1D |
| 95 |
IND |
***** input. This is an exact, algebraic function. */ |
| 96 |
|
virtual VectorType EvaluateDerivative(const InputType & input) const; |
| 97 |
|
|
| 98 |
|
/** Add another harmonic's frequency coefficients. */ |
| 99 |
|
void AddHarmonic( const VectorType & CosCoefficients, |
| 100 |
|
const VectorType & SinCoefficients ); |
| 101 |
|
|
| 102 |
|
/** Clear all frequency coefficients (including the "DC" coefficients). */ |
| 103 |
|
void Clear() |
| 104 |
|
{ |
| 105 |
|
m_CosCoefficients->Initialize(); |
| 106 |
|
m_SinCoefficients->Initialize(); |
| 107 |
|
this->Modified(); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
/** New() method for dynamic construction */ |
| 111 |
|
itkNewMacro( Self ); |
| 112 |
|
|
| 113 |
IND |
****/** Needed for Pipelining */ |
| 114 |
|
virtual void Initialize(void) |
| 115 |
|
{ |
| 116 |
|
this->Clear(); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
protected: |
| 120 |
|
FourierSeriesPath(); |
| 121 |
|
~FourierSeriesPath(){} |
| 122 |
|
void PrintSelf(std::ostream& os, Indent indent) const; |
| 123 |
|
|
| 124 |
|
private: |
| 125 |
|
FourierSeriesPath(const Self&); //purposely not implemented |
| 126 |
|
void operator=(const Self&); //purposely not implemented |
| 127 |
|
|
| 128 |
|
CoefficientsPointer m_CosCoefficients; |
| 129 |
|
CoefficientsPointer m_SinCoefficients; |
| 130 |
|
}; |
| 131 |
|
|
| 132 |
|
} // namespace itk |
| 133 |
|
|
| 134 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 135 |
|
#include "itkFourierSeriesPath.txx" |
| 136 |
|
#endif |
| 137 |
|
|
| 138 |
|
#endif |
| 139 |
|
|