ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkFlatStructuringElement.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkFlatStructuringElement_h
00019 #define __itkFlatStructuringElement_h
00020 
00021 #include "itkNeighborhood.h"
00022 #include <vector>
00023 #include "itkVector.h"
00024 
00025 namespace itk
00026 {
00044 template< unsigned int VDimension >
00045 class ITK_EXPORT FlatStructuringElement:public Neighborhood< bool, VDimension >
00046 {
00047 public:
00049   typedef FlatStructuringElement< VDimension > Self;
00050   typedef Neighborhood< bool, VDimension >     Superclass;
00051 
00053   typedef typename Superclass::PixelType PixelType;
00054 
00058   typedef typename Superclass::Iterator      Iterator;
00059   typedef typename Superclass::ConstIterator ConstIterator;
00060 
00062   typedef typename Superclass::SizeType      SizeType;
00063   typedef typename Superclass::OffsetType    OffsetType;
00064 
00066   typedef typename Superclass::RadiusType RadiusType;
00067 
00069   typedef typename Superclass::SliceIteratorType SliceIteratorType;
00070 
00072   itkStaticConstMacro(NeighborhoodDimension, unsigned int, VDimension);
00073 
00074   typedef Vector< float, VDimension > LType;
00075   typedef std::vector< LType >        DecompType;
00076 
00078   virtual ~FlatStructuringElement() {}
00079 
00081   FlatStructuringElement() { m_Decomposable = false; }
00082 
00089   static Self Box(RadiusType radius);
00090 
00092   static Self Ball(RadiusType radius);
00093 
00095   static Self Cross(RadiusType radius);
00096 
00098   static Self Annulus(RadiusType radius,
00099                       unsigned int thickness = 1,
00100                       bool includeCenter = false);
00101 
00107   static Self Polygon(RadiusType radius, unsigned lines);
00108 
00114   bool GetDecomposable() const
00115   {
00116     return m_Decomposable;
00117   }
00118   void SetDecomposable( bool v )
00119   {
00120     m_Decomposable = v;
00121   }
00123 
00125   const DecompType & GetLines() const
00126   {
00127     return ( m_Lines );
00128   }
00129   void AddLine( LType l )
00130   {
00131     m_Lines.push_back(l);
00132   }
00134 
00135   bool CheckParallel(LType NewVec) const;
00136 
00141   void ComputeBufferFromLines();
00142 
00143 protected:
00144 
00145   void PrintSelf(std::ostream & os, Indent indent) const;
00146 
00147 private:
00148   bool m_Decomposable;
00149 
00150   DecompType m_Lines;
00151 
00152   template< unsigned int VDimension3 >
00153   struct StructuringElementFacet {
00154     Vector< float, VDimension3 > P1, P2, P3;
00155   };
00156   typedef StructuringElementFacet< VDimension > FacetType;
00157 
00158   template<class TStructuringElement, class TRadius>
00159   static void GeneratePolygon(TStructuringElement & res,            TRadius      radius, unsigned lines);
00160   static void GeneratePolygon(itk::FlatStructuringElement<2> & res, itk::Size<2> radius, unsigned lines);
00161   static void GeneratePolygon(itk::FlatStructuringElement<3> & res, itk::Size<3> radius, unsigned lines);
00162 
00163   typedef Vector< float, 2 >           LType2;
00164 
00165   typedef Vector< float, 3 >           LType3;
00166   typedef StructuringElementFacet< 3 > FacetType3;
00167 
00168 };
00169 } // namespace itk
00170 
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "itkFlatStructuringElement.hxx"
00173 #endif
00174 
00175 #endif
00176