Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkChainCodePath2D.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkChainCodePath2D.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:03 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef _itkChainCodePath2D_h 00019 #define _itkChainCodePath2D_h 00020 00021 #include "itkChainCodePath.h" 00022 #include "itkObjectFactory.h" 00023 #include "itkIndex.h" 00024 #include "itkOffset.h" 00025 #include <vector> 00026 #include <string> 00027 00028 00029 namespace itk 00030 { 00031 00032 00050 class ITKCommon_EXPORT ChainCodePath2D : public 00051 ChainCodePath<2> 00052 { 00053 public: 00055 itkStaticConstMacro(Dimension, unsigned int, 2); 00056 00058 typedef ChainCodePath2D Self; 00059 typedef ChainCodePath<2> Superclass; 00060 00061 typedef SmartPointer<Self> Pointer; 00062 typedef SmartPointer<const Self> ConstPointer; 00063 00065 itkTypeMacro(ChainCodePath2D, ChainCodePath); 00066 00067 00069 typedef Superclass::OutputType OutputType; 00070 typedef Superclass::InputType InputType; 00071 00073 typedef OutputType OffsetType; 00074 typedef Index<2> IndexType; 00075 00077 typedef std::vector<OffsetType> ChainCodeType; 00079 typedef std::vector<int> ChainCode2DType; 00080 00081 00082 00083 // Functions inherited from Path 00084 00086 virtual OutputType Evaluate( const InputType & input ) const; 00087 00089 virtual IndexType EvaluateToIndex( const InputType & input ) const; 00090 00095 virtual OffsetType IncrementInput(InputType & input) const; 00096 00097 00098 00099 // Functions specific to ChainCodePath and its descendents 00100 00102 itkNewMacro( Self ); 00103 00105 inline unsigned int NumberOfSteps() const { return m_Chain2D.size(); } 00106 00107 00109 inline void InsertStep( InputType position, int encodedStep ) 00110 { 00111 m_Chain2D.insert( m_Chain2D.begin()+position, encodedStep ); 00112 this->Modified(); 00113 } 00114 inline void InsertStep( InputType position, OffsetType step ) 00115 { 00116 m_Chain2D.insert( m_Chain2D.begin()+position, EncodeOffset(step) ); 00117 this->Modified(); 00118 } 00119 00120 00122 inline void ChangeStep( InputType position, int encodedStep ) 00123 { 00124 m_Chain2D[position]=encodedStep; 00125 this->Modified(); 00126 } 00127 inline void ChangeStep( InputType position, OffsetType step ) 00128 { 00129 m_Chain2D[position]=EncodeOffset(step); 00130 this->Modified(); 00131 } 00132 00134 virtual inline void Clear() 00135 { 00136 m_Chain2D.clear(); 00137 this->Modified(); 00138 } 00139 00140 std::string GetChainCodeAsString(void) const; 00141 00142 00143 00144 protected: 00145 ChainCodePath2D(); 00146 ~ChainCodePath2D() {} 00147 void PrintSelf(std::ostream& os, Indent indent) const; 00148 00150 inline int EncodeOffset( OffsetType step ) const 00151 { 00152 return m_FreemanCode[ step[0] + 1 ][ step[1] + 1 ]; 00153 } 00154 inline OffsetType DecodeOffset( int encodedStep ) const 00155 { 00156 return m_ReverseFreemanCode[ encodedStep ]; 00157 } 00158 00159 00160 00161 private: 00162 ChainCodePath2D(const Self&); //purposely not implemented 00163 void operator=(const Self&); //purposely not implemented 00164 00165 ChainCode2DType m_Chain2D; // the Freeman-encoded chain code 00166 00167 // FreemanCode[][] implements a lookup table for converting offsets to a 00168 // Freeman code. Within each dimension, the only allowable offset values are 00169 // { -1, 0, 1 }. The y-axis is assumed to point up. It is initialized in the 00170 // constructor. Use it as follows: 00171 // 00172 // encodedValue = m_FreemanCode[ x offset + 1 ][ y offset + 1 ] 00173 // 00174 int m_FreemanCode[3][3]; 00175 00176 // m_ReverseFreemanCode[ encodedValue ] implements a lookup table for the 00177 // inverse of m_FreemanCode[][]. It is initialized in the constructor. 00178 OffsetType m_ReverseFreemanCode[9]; 00179 }; 00180 00181 } // namespace itk 00182 00183 #endif

Generated at Sat Mar 31 02:15:39 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000