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-12-10 10:55:21 $
00007   Version:   $Revision: 1.4 $
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 
00278   void Optimize();
00279 
00280 protected:
00281   LabelMap();
00282   virtual ~LabelMap() {};
00283   void PrintSelf(std::ostream& os, Indent indent) const;
00284 
00285 private:
00286   LabelMap(const Self&); //purposely not implemented
00287   void operator=(const Self&); //purposely not implemented
00288 
00289   LabelObjectContainerType m_LabelObjectContainer;
00290   LabelType                m_BackgroundValue;
00291 };
00292 
00293 } // end namespace itk
00294 
00295 
00296 #ifndef ITK_MANUAL_INSTANTIATION
00297 # include "itkLabelMap.txx"
00298 #endif
00299 
00300 #endif
00301 

Generated at Mon Jul 12 2010 18:57:32 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000