00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkKLMSegmentationBorder_h
00018 #define _itkKLMSegmentationBorder_h
00019
00020 #include "itkObject.h"
00021 #include "itkSegmentationBorder.h"
00022
00023 #include "itkKLMSegmentationRegion.h"
00024 #include "itkExceptionObject.h"
00025
00026 #include "vnl/vnl_math.h"
00027 #include "vnl/vnl_vector.h"
00028
00029 namespace itk
00030 {
00031
00041 template <class TBorder>
00042 class KLMDynamicBorderArray
00043 {
00044 public:
00052 bool operator> (const KLMDynamicBorderArray<TBorder>& rhs) const
00053 {
00054 if( m_Pointer->GetLambda() == rhs.m_Pointer->GetLambda() )
00055 {
00056 if( m_Pointer->GetLambda() < 0 )
00057 {
00058 return ( m_Pointer > rhs.m_Pointer );
00059 }
00060 else
00061 {
00062
00063
00064
00065
00066
00067
00068 unsigned int v1 = vnl_math_max(
00069 m_Pointer->GetRegion1()->GetRegionBorderSize(),
00070 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
00093
00094
00095
00096
00097
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);
00167
00169 void EvaluateLambda();
00170
00172 void PrintBorderInfo();
00173
00174 protected:
00176 KLMSegmentationBorder();
00177
00179 ~KLMSegmentationBorder();
00180
00182 void PrintSelf(std::ostream& os, Indent indent) const;
00183
00184 private:
00185 KLMSegmentationBorder(const Self&);
00186 void operator=(const Self&);
00187
00188 double m_Lambda;
00189 KLMSegmentationRegion *m_Region1;
00190 KLMSegmentationRegion *m_Region2;
00191
00192 };
00193
00194
00195 }
00196
00197
00198 #endif