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

itkLabelMap.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkLabelMap.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-14 21:08:43 $
00007   Version:   $Revision: 1.3 $
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 #ifndef __itkLabelMap_h
00018 #define __itkLabelMap_h
00019 
00020 #include "itkImageBase.h"
00021 #include "itkImageRegion.h"
00022 #include "itkFixedArray.h"
00023 #include "itkWeakPointer.h"
00024 #include <map>
00025 
00026 namespace itk
00027 {
00056 template <class TLabelObject >
00057 class ITK_EXPORT LabelMap : public ImageBase< ::itk::GetImageDimension<TLabelObject>::ImageDimension>
00058 {
00059 public:
00061   typedef LabelMap                                 Self;
00062   typedef ImageBase< ::itk::GetImageDimension<TLabelObject>::ImageDimension>
00063                                                    Superclass;
00064   typedef SmartPointer<Self>                       Pointer;
00065   typedef SmartPointer<const Self>                 ConstPointer;
00066   typedef WeakPointer<const Self>                  ConstWeakPointer;
00067 
00069   itkNewMacro(Self);
00070 
00072   itkTypeMacro(LabelMap, ImageBase);
00073 
00074   typedef TLabelObject LabelObjectType;
00075 
00076   typedef typename LabelObjectType::Pointer LabelObjectPointerType;
00077 
00082   itkStaticConstMacro(ImageDimension, unsigned int, LabelObjectType::ImageDimension);
00083 
00085   typedef typename LabelObjectType::LabelType  LabelType;
00086   typedef LabelType                            PixelType;
00087 
00089   typedef std::map< LabelType, LabelObjectPointerType > LabelObjectContainerType;
00090 
00092   typedef std::vector< LabelType >              LabelVectorType;
00093   typedef std::vector< LabelObjectPointerType > LabelObjectVectorType;
00094 
00096   typedef typename Superclass::IndexType  IndexType;
00097 
00099   typedef typename Superclass::OffsetType OffsetType;
00100 
00102   typedef typename Superclass::SizeType  SizeType;
00103 
00105   typedef typename Superclass::DirectionType  DirectionType;
00106 
00108   typedef typename Superclass::RegionType  RegionType;
00109 
00112   typedef typename Superclass::SpacingType SpacingType;
00113 
00116   typedef typename Superclass::PointType PointType;
00117 
00119   typedef typename Superclass::OffsetValueType OffsetValueType;
00120 
00124   void SetRegions( const RegionType & region )
00125     {
00126     this->SetLargestPossibleRegion(region);
00127     this->SetBufferedRegion(region);
00128     this->SetRequestedRegion(region);
00129     }
00131 
00132   void SetRegions( const SizeType & size )
00133     {
00134     RegionType region; region.SetSize(size);
00135     this->SetLargestPossibleRegion(region);
00136     this->SetBufferedRegion(region);
00137     this->SetRequestedRegion(region);
00138     }
00139 
00142   virtual void Initialize();
00143 
00145   virtual void Allocate();
00146 
00147   virtual void Graft(const DataObject *data);
00148 
00154   LabelObjectType * GetLabelObject( const LabelType & label );
00155 
00156   const LabelObjectType * GetLabelObject( const LabelType & label ) const;
00157 
00163   bool HasLabel( const LabelType label ) const;
00164 
00171   LabelObjectType * GetNthLabelObject( const unsigned long & pos );
00172 
00173   const LabelObjectType * GetNthLabelObject( const unsigned long & pos ) const;
00174 
00180   const LabelType & GetPixel( const IndexType & idx ) const;
00181 
00190   void SetPixel( const IndexType & idx, const LabelType & label );
00191 
00199   void SetLine( const IndexType & idx, const unsigned long & length, const LabelType & label );
00200 
00206   LabelObjectType * GetLabelObject( const IndexType & idx ) const;
00207 
00212   void AddLabelObject( LabelObjectType * labelObject );
00213 
00218   void PushLabelObject( LabelObjectType * labelObject );
00219 
00223   void RemoveLabelObject( LabelObjectType * labelObject );
00224 
00228   void RemoveLabel( const LabelType & label );
00229 
00233   void ClearLabels();
00234 
00238   const LabelObjectContainerType & GetLabelObjectContainer() const;
00239   LabelObjectContainerType & GetLabelObjectContainer();
00241 
00245   unsigned long GetNumberOfLabelObjects() const;
00246 
00250   LabelVectorType GetLabels() const;
00251 
00255   LabelObjectVectorType GetLabelObjects() const;
00256 
00260   itkGetConstMacro(BackgroundValue, LabelType);
00261   itkSetMacro(BackgroundValue, LabelType);
00263 
00268   void PrintLabelObjects(std::ostream& os) const;
00269   void PrintLabelObjects() const
00270     {
00271     this->PrintLabelObjects( std::cerr );
00272     }
00274 
00275 protected:
00276   LabelMap();
00277   virtual ~LabelMap() {};
00278   void PrintSelf(std::ostream& os, Indent indent) const;
00279 
00280 private:
00281   LabelMap(const Self&); //purposely not implemented
00282   void operator=(const Self&); //purposely not implemented
00283 
00284   LabelObjectContainerType m_LabelObjectContainer;
00285   LabelType                m_BackgroundValue;
00286 };
00287 
00288 } // end namespace itk
00289 
00290 
00291 #ifndef ITK_MANUAL_INSTANTIATION
00292 # include "itkLabelMap.txx"
00293 #endif
00294 
00295 #endif
00296 

Generated at Thu May 28 10:37:32 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000