00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkRGBGibbsPriorFilter_h
00018 #define __itkRGBGibbsPriorFilter_h
00019
00020 #include "vnl/vnl_vector.h"
00021 #include "vnl/vnl_matrix.h"
00022
00023 #include "itkImageToImageFilter.h"
00024 #include "itkImageClassifierBase.h"
00025 #include "itkImageRegionIterator.h"
00026 #include "itkMRFImageFilter.h"
00027
00028 namespace itk
00029 {
00030
00046 template <class TInputImage, class TClassifiedImage>
00047 class ITK_EXPORT RGBGibbsPriorFilter : public MRFImageFilter<TInputImage,
00048 TClassifiedImage>
00049 {
00050 public:
00052 typedef RGBGibbsPriorFilter Self;
00053
00055 typedef MRFImageFilter<TInputImage, TClassifiedImage> Superclass;
00056
00058 typedef SmartPointer<Self> Pointer;
00059 typedef SmartPointer<const Self> ConstPointer;
00060
00062 itkNewMacro(Self);
00063
00065 itkTypeMacro(RGBGibbsPriorFilter,MRFImageFilter);
00066
00068 typedef typename Superclass::InputImagePixelType InputImagePixelType;
00069 typedef typename Superclass::InputImageRegionConstIterator InputImageRegionConstIterator;
00070 typedef typename Superclass::InputImageRegionIterator InputImageRegionIterator;
00071 typedef typename Superclass::LabelledImageRegionIterator LabelledImageRegionIterator;
00072 typedef typename Superclass::LabelledImagePixelType LabelledImagePixelType;
00073 typedef typename Superclass::IndexValueType IndexValueType;
00074
00076 typedef TInputImage InputImageType;
00077 typedef typename TInputImage::Pointer InputImagePointer;
00078 typedef typename TInputImage::ConstPointer InputImageConstPointer;
00079
00081 typedef typename TInputImage::PixelType InputPixelType;
00082
00084 typedef typename TClassifiedImage::Pointer TrainingImageType;
00085
00088 typedef typename TClassifiedImage::Pointer LabelledImageType;
00089
00091 typedef typename TClassifiedImage::IndexType LabelledImageIndexType;
00092
00096 typedef unsigned int LabelType;
00097
00099 typedef ImageClassifierBase<TInputImage,TClassifiedImage> ClassifierType;
00100
00102 typedef typename TInputImage::PixelType InputImageVecType;
00103 typedef typename TInputImage::IndexType IndexType;
00104
00106 void SetTrainingImage(TrainingImageType image);
00107
00109 void SetLabelledImage(LabelledImageType LabelledImage);
00110
00112 LabelledImageType GetLabelledImage()
00113 { return m_LabelledImage; }
00114
00116 void SetClassifier( typename ClassifierType::Pointer ptrToClassifier );
00117
00119 itkSetMacro(NumberOfClasses, unsigned int);
00120
00122 itkGetMacro(NumberOfClasses, unsigned int);
00123
00126 itkSetMacro(MaximumNumberOfIterations, unsigned int);
00127
00130 itkGetMacro(MaximumNumberOfIterations, unsigned int);
00131
00133 itkSetMacro(ClusterSize, unsigned int);
00134
00136 itkSetMacro( ObjectLabel, LabelType );
00137
00139 itkStaticConstMacro(ImageDimension, unsigned int,
00140 TInputImage::ImageDimension);
00141
00142 itkSetMacro(StartPoint, IndexType);
00143
00144 itkSetMacro(BoundaryGradient, unsigned int);
00145
00146 itkSetMacro(ObjectThreshold, double);
00147
00149 itkSetMacro(CliqueWeight_1, double);
00150 itkGetMacro(CliqueWeight_1, double);
00151 itkSetMacro(CliqueWeight_2, double);
00152 itkGetMacro(CliqueWeight_2, double);
00153 itkSetMacro(CliqueWeight_3, double);
00154 itkGetMacro(CliqueWeight_3, double);
00155 itkSetMacro(CliqueWeight_4, double);
00156 itkGetMacro(CliqueWeight_4, double);
00157 itkSetMacro(CliqueWeight_5, double);
00158 itkGetMacro(CliqueWeight_5, double);
00159 itkSetMacro(CliqueWeight_6, double);
00160 itkGetMacro(CliqueWeight_6, double);
00162
00163
00165 typedef vnl_matrix<double> MatrixType;
00166
00167 protected:
00168 RGBGibbsPriorFilter();
00169 ~RGBGibbsPriorFilter();
00170 void PrintSelf(std::ostream& os, Indent indent) const;
00171
00174 virtual void MinimizeFunctional();
00175 virtual void GenerateData();
00176 virtual void ApplyGibbsLabeller();
00177 virtual void ApplyGPImageFilter();
00178
00179
00180 private:
00181 RGBGibbsPriorFilter(const Self&);
00182 void operator=(const Self&);
00183
00184 typedef typename TInputImage::SizeType InputImageSizeType;
00185
00195 typename ClassifierType::Pointer m_ClassifierPtr;
00196
00216 unsigned int m_ImageHeight;
00217 unsigned int m_ImageDepth;
00218
00246 void GibbsTotalEnergy(int i);
00247
00249 double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
00250
00261 double m_ObjectThreshold;
00262
00263 };
00264
00265 }
00266 #ifndef ITK_MANUAL_INSTANTIATION
00267 #include "itkRGBGibbsPriorFilter.txx"
00268 #endif
00269 #endif
00270