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

itkKLMSegmentationBorder.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkKLMSegmentationBorder.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006/02/06 22:01:56 $
00007   Version:   $Revision: 1.10 $
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 __itkKLMSegmentationBorder_h
00018 #define __itkKLMSegmentationBorder_h
00019 
00020 #include "itkObject.h"
00021 #include "itkSegmentationBorder.h"
00022 #include "itkKLMSegmentationRegion.h"
00023 #include "itkExceptionObject.h"
00024 
00025 #include "vnl/vnl_math.h"
00026 #include "vnl/vnl_vector.h"
00027 
00028 namespace itk
00029 {
00030 
00040 template <class TBorder>
00041 class KLMDynamicBorderArray
00042 {
00043 public:
00051   bool operator> (const KLMDynamicBorderArray<TBorder>& rhs) const
00052     {
00053     if( m_Pointer->GetLambda() == rhs.m_Pointer->GetLambda() )
00054       {
00055       if( m_Pointer->GetLambda() < 0 )
00056         {
00057         return ( m_Pointer > rhs.m_Pointer );
00058         }
00059       else
00060         {
00061         // The purpose of this comparison is to not let any one region
00062         // get more borders than another region.  In the degenerate
00063         // case of an image where the Lambdas are always equal to some
00064         // constant C, allowing a single region to be repeatedly
00065         // merged so that it gains many borders will result in
00066         // pathologically slow behavior.
00067         unsigned int v1 = vnl_math_max(
00068           m_Pointer->GetRegion1()->GetRegionBorderSize(),
00069           m_Pointer->GetRegion2()->GetRegionBorderSize() );
00071 
00072         unsigned int v2 = vnl_math_max(
00073           rhs.m_Pointer->GetRegion1()->GetRegionBorderSize(),
00074           rhs.m_Pointer->GetRegion2()->GetRegionBorderSize() );
00075 
00076         return ( v1 > v2 );
00077         }
00078       }
00079     return(m_Pointer->GetLambda() > rhs.m_Pointer->GetLambda() );
00080     }
00081 
00082   bool operator> (const KLMDynamicBorderArray<TBorder>* rhs) const
00083     {
00084     if( m_Pointer->GetLambda() == rhs.m_Pointer->GetLambda() )
00085       {
00086       if( m_Pointer->GetLambda() < 0 )
00087         {
00088         return ( m_Pointer > rhs.m_Pointer );
00089         }
00090       else
00091         {
00092         // The purpose of this comparison is to not let any one region
00093         // get more borders than another region.  In the degenerate
00094         // case of an image where the Lambdas are always equal to some
00095         // constant C, allowing a single region to be repeatedly
00096         // merged so that it gains many borders will result in
00097         // pathologically slow behavior.
00098         unsigned int v1 = vnl_math_max(
00099           m_Pointer->GetRegion1()->GetRegionBorderSize(),
00100           m_Pointer->GetRegion2()->GetRegionBorderSize() );
00101 
00102         unsigned int v2 = vnl_math_max(
00103           rhs.m_Pointer->GetRegion1()->GetRegionBorderSize(),
00104           rhs.m_Pointer->GetRegion2()->GetRegionBorderSize() );
00105 
00106         return ( v1 > v2 );
00107         }
00108       }
00109     return(m_Pointer->GetLambda() > rhs.m_Pointer->GetLambda() );
00110     }
00111 
00112   TBorder *m_Pointer;
00113 };
00114 
00133 class KLMSegmentationRegion;
00134 
00135 class ITKCommon_EXPORT KLMSegmentationBorder : public SegmentationBorder
00136 {
00137 
00138 public:
00140   typedef KLMSegmentationBorder   Self;
00141   typedef SegmentationBorder Superclass;
00142   typedef SmartPointer<Self>  Pointer;
00143   typedef SmartPointer<const Self>  ConstPointer;
00144 
00146   itkNewMacro(Self);
00147 
00149   itkTypeMacro(KLMSegmentationBorder,SegmentationBorder);
00150 
00152   void SetRegion1(KLMSegmentationRegion *Region1);
00153 
00155   KLMSegmentationRegion *GetRegion1();
00156 
00158   void SetRegion2(KLMSegmentationRegion *Region2);
00159 
00161   KLMSegmentationRegion *GetRegion2();
00162 
00165   itkSetMacro(Lambda, double);
00166   itkGetConstReferenceMacro(Lambda, double);
00168 
00170   void EvaluateLambda();
00171 
00173   void PrintBorderInfo();
00174 
00175 protected:
00177   KLMSegmentationBorder();
00178 
00180   ~KLMSegmentationBorder();
00181 
00183   void PrintSelf(std::ostream& os, Indent indent) const;
00184 
00185 private:
00186   KLMSegmentationBorder(const Self&); //purposely not implemented
00187   void operator=(const Self&); //purposely not implemented
00188 
00189   double m_Lambda;
00190   KLMSegmentationRegion *m_Region1;
00191   KLMSegmentationRegion *m_Region2;
00192 
00193 };
00194 
00195 
00196 } // end namespace itk
00197 
00198 
00199 #endif
00200 

Generated at Sun Sep 23 13:19:48 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000