00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkAntiAliasBinaryImageFilter_h_
00018 #define __itkAntiAliasBinaryImageFilter_h_
00019 #include "itkSparseFieldLevelSetImageFilter.h"
00020 #include "itkCurvatureFlowFunction.h"
00021
00022 namespace itk {
00023
00099 template <class TInputImage, class TOutputImage>
00100 class AntiAliasBinaryImageFilter
00101 : public SparseFieldLevelSetImageFilter<TInputImage, TOutputImage>
00102 {
00103 public:
00105 typedef AntiAliasBinaryImageFilter Self;
00106 typedef SparseFieldLevelSetImageFilter<TInputImage, TOutputImage> Superclass;
00107 typedef SmartPointer<Self> Pointer;
00108 typedef SmartPointer<const Self> ConstPointer;
00109
00111 typedef typename Superclass::ValueType ValueType;
00112 typedef typename Superclass::IndexType IndexType;
00113 typedef typename Superclass::TimeStepType TimeStepType;
00114 typedef typename Superclass::OutputImageType OutputImageType;
00115 typedef typename Superclass::InputImageType InputImageType;
00116
00117
00119 typedef CurvatureFlowFunction<OutputImageType> CurvatureFunctionType;
00120
00122 typedef typename TInputImage::ValueType BinaryValueType;
00123
00125 itkNewMacro(Self);
00126
00128 itkTypeMacro(AntiAliasBinaryImageFilter, SparseFieldLevelSetImageFilter);
00129
00132 itkSetMacro(MaximumRMSError, ValueType);
00133 itkGetMacro(MaximumRMSError, ValueType);
00134
00139 itkSetMacro(MaximumIterations, unsigned int);
00140 itkGetMacro(MaximumIterations, unsigned int);
00141
00143 itkGetMacro(UpperBinaryValue, BinaryValueType);
00144 itkGetMacro(LowerBinaryValue, BinaryValueType);
00145
00146 protected:
00147 AntiAliasBinaryImageFilter();
00148 ~AntiAliasBinaryImageFilter() {}
00149 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00150
00153 inline virtual ValueType CalculateUpdateValue(const IndexType &idx,
00154 const TimeStepType &dt,
00155 const ValueType &value,
00156 const ValueType &change);
00157
00160 bool Halt()
00161 {
00162 if (this->GetElapsedIterations() >= m_MaximumIterations)
00163 {
00164 itkWarningMacro("This filter has passed the maximum number of iterations allowed and will be halted. This means that the solution did not converge to the MaximumRMSError you specified. Try setting m_MaximumRMSError to a higher value, or set m_MaxmimumIterations to a higher value.");
00165 return true;
00166 }
00167 else if ( this->GetElapsedIterations() == 0)
00168 { return false; }
00169 else if ( this->GetRMSChange() <= m_MaximumRMSError )
00170 { return true; }
00171 else
00172 { return false; }
00173 }
00174
00177 void GenerateData();
00178
00179 private:
00180 ValueType m_MaximumRMSError;
00181 BinaryValueType m_UpperBinaryValue;
00182 BinaryValueType m_LowerBinaryValue;
00183 typename CurvatureFunctionType::Pointer m_CurvatureFunction;
00184
00185 unsigned int m_MaximumIterations;
00186
00187 };
00188
00189 }
00190
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkAntiAliasBinaryImageFilter.txx"
00193 #endif
00194
00195 #endif