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

itkRelabelComponentImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkRelabelComponentImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/08/03 18:50:05 $
00007   Version:   $Revision: 1.12 $
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 __itkRelabelComponentImageFilter_h
00018 #define __itkRelabelComponentImageFilter_h
00019 
00020 #include "itkInPlaceImageFilter.h"
00021 #include "itkImage.h"
00022 #include <vector>
00023 
00024 namespace itk
00025 {
00026 
00071 template <class TInputImage, class TOutputImage>
00072 class ITK_EXPORT RelabelComponentImageFilter : 
00073     public InPlaceImageFilter< TInputImage, TOutputImage > 
00074 {
00075 public:
00079   typedef RelabelComponentImageFilter Self;
00080   typedef InPlaceImageFilter< TInputImage, TOutputImage > Superclass;
00081 
00085   typedef typename Superclass::InputImagePointer InputImagePointer;
00086 
00091   typedef typename TOutputImage::PixelType OutputPixelType;
00092   typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
00093   typedef typename TInputImage::PixelType InputPixelType;
00094   typedef typename TInputImage::InternalPixelType InputInternalPixelType;
00095   itkStaticConstMacro(ImageDimension, unsigned int,
00096                       TOutputImage::ImageDimension);
00097   
00101   typedef TInputImage  InputImageType;
00102   typedef TOutputImage OutputImageType;
00103   typedef   typename TInputImage::IndexType       IndexType;
00104   typedef   typename TInputImage::SizeType        SizeType;
00105   typedef   typename TOutputImage::RegionType     RegionType;
00106 
00110   typedef SmartPointer<Self> Pointer;
00111   typedef SmartPointer<const Self>  ConstPointer;
00112   
00116   itkTypeMacro(RelabelComponentImageFilter, ImageToImageFilter);
00117   
00121   itkNewMacro(Self);
00122 
00125   itkGetMacro(NumberOfObjects, unsigned long);
00126   
00132   itkGetMacro(OriginalNumberOfObjects, unsigned long);
00133 
00136   itkSetMacro(NumberOfObjectsToPrint, unsigned long);
00137   itkGetConstReferenceMacro(NumberOfObjectsToPrint, unsigned long);
00138 
00145   itkSetMacro(MinimumObjectSize, unsigned long);
00146 
00152   itkGetMacro(MinimumObjectSize, unsigned long);
00153    
00159   const std::vector<unsigned long>& GetSizeOfObjectsInPixels() const
00160     { return m_SizeOfObjectsInPixels; }
00161 
00167   const std::vector<float>& GetSizeOfObjectsInPhysicalUnits() const
00168     { return m_SizeOfObjectsInPhysicalUnits; }
00169 
00173   unsigned long GetSizeOfObjectInPixels(unsigned long obj) const
00174     {
00175       if (obj > 0 && obj <= m_NumberOfObjects)
00176         {
00177         return m_SizeOfObjectsInPixels[obj-1];
00178         }
00179       else
00180         {
00181         return 0;
00182         }
00183     }
00184 
00188   float GetSizeOfObjectInPhysicalUnits(unsigned long obj) const
00189     { 
00190       if (obj > 0 && obj <= m_NumberOfObjects)
00191         {
00192         return m_SizeOfObjectsInPhysicalUnits[obj-1];
00193         }
00194       else
00195         {
00196         return 0;
00197         }
00198     }  
00199 
00200   
00201 protected:
00202 
00203   RelabelComponentImageFilter()
00204     : m_NumberOfObjects(0), m_NumberOfObjectsToPrint(10),
00205     m_OriginalNumberOfObjects(0), m_MinimumObjectSize(0)
00206     { this->InPlaceOff(); }
00207   virtual ~RelabelComponentImageFilter() {}
00208   RelabelComponentImageFilter(const Self&) {}
00209 
00213   void GenerateData();
00214 
00218   void GenerateInputRequestedRegion();
00219 
00221   void PrintSelf(std::ostream& os, Indent indent) const;
00222 
00223   struct RelabelComponentObjectType
00224   {
00225     unsigned long m_ObjectNumber;
00226     unsigned long m_SizeInPixels;
00227     float m_SizeInPhysicalUnits;
00228   };
00229 
00230   // put the function objects here for sorting in descending order
00231   class RelabelComponentSizeInPixelsComparator
00232   {
00233   public:
00234     bool operator()(const RelabelComponentObjectType&a, 
00235                     const RelabelComponentObjectType &b)
00236       {
00237         if (a.m_SizeInPixels > b.m_SizeInPixels)
00238           {
00239           return true;
00240           }
00241         else if (a.m_SizeInPixels < b.m_SizeInPixels)
00242           {
00243           return false;
00244           }
00245         // size in pixels and physical units are the same, sort based on
00246         // original object number
00247         else if (a.m_ObjectNumber < b.m_ObjectNumber)
00248           {
00249           return true;
00250           }
00251         else
00252           {
00253           return false;
00254           }
00255       }
00256   };
00257 
00258 
00259 private:
00260 
00261   unsigned long m_NumberOfObjects;
00262   unsigned long m_NumberOfObjectsToPrint;
00263   unsigned long m_OriginalNumberOfObjects;
00264   unsigned long m_MinimumObjectSize;
00265   std::vector<unsigned long> m_SizeOfObjectsInPixels;
00266   std::vector<float> m_SizeOfObjectsInPhysicalUnits;
00267 
00268 };
00269   
00270 } // end namespace itk
00271 
00272 #ifndef ITK_MANUAL_INSTANTIATION
00273 #include "itkRelabelComponentImageFilter.txx"
00274 #endif
00275 
00276 #endif

Generated at Wed May 24 23:58:25 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000