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 ITK_EXPORT 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
00163 this->UpdateProgress( static_cast<float>( this->GetElapsedIterations() ) /
00164 static_cast<float>( m_MaximumIterations ) );
00165
00166 if (this->GetElapsedIterations() >= m_MaximumIterations)
00167 {
00168 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.");
00169 return true;
00170 }
00171 else if ( this->GetElapsedIterations() == 0)
00172 {
00173 return false;
00174 }
00175 else if ( this->GetRMSChange() <= m_MaximumRMSError )
00176 {
00177 return true;
00178 }
00179 else
00180 {
00181 return false;
00182 }
00183 }
00184
00187 void GenerateData();
00188
00189 private:
00190 ValueType m_MaximumRMSError;
00191 BinaryValueType m_UpperBinaryValue;
00192 BinaryValueType m_LowerBinaryValue;
00193 typename CurvatureFunctionType::Pointer m_CurvatureFunction;
00194
00195 unsigned int m_MaximumIterations;
00196
00197 };
00198
00199 }
00200
00201 #ifndef ITK_MANUAL_INSTANTIATION
00202 #include "itkAntiAliasBinaryImageFilter.txx"
00203 #endif
00204
00205 #endif