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
00147 itkSetMacro(CliqueWeight_1, double);
00148 itkGetMacro(CliqueWeight_1, double);
00149 itkSetMacro(CliqueWeight_2, double);
00150 itkGetMacro(CliqueWeight_2, double);
00151 itkSetMacro(CliqueWeight_3, double);
00152 itkGetMacro(CliqueWeight_3, double);
00153 itkSetMacro(CliqueWeight_4, double);
00154 itkGetMacro(CliqueWeight_4, double);
00155
00157 typedef vnl_matrix<double> MatrixType;
00158
00159 protected:
00160 RGBGibbsPriorFilter();
00161 ~RGBGibbsPriorFilter();
00162 void PrintSelf(std::ostream& os, Indent indent) const;
00163
00164 void Allocate();
00166 virtual void MinimizeFunctional();
00167 virtual void GenerateData();
00168 virtual void ApplyGibbsLabeller();
00169 virtual void ApplyGPImageFilter();
00170
00171
00172 private:
00173 RGBGibbsPriorFilter(const Self&);
00174 void operator=(const Self&);
00175
00176 typedef typename TInputImage::SizeType InputImageSizeType;
00177
00178 InputImageConstPointer m_InputImage;
00179 TrainingImageType m_TrainingImage;
00180 LabelledImageType m_LabelledImage;
00181 unsigned int m_NumberOfClasses;
00182 unsigned int m_MaximumNumberOfIterations;
00183 typename ClassifierType::Pointer m_ClassifierPtr;
00184 unsigned int m_BoundaryGradient;
00185 double m_BoundaryWeight;
00186 double m_GibbsPriorWeight;
00187 int m_StartRadius;
00188 int m_RecursiveNum;
00189 LabelType * m_LabelStatus;
00191 InputImagePointer m_MediumImage;
00193 unsigned int m_Temp;
00194 IndexType m_StartPoint;
00196 unsigned int m_ImageWidth;
00197 unsigned int m_ImageHeight;
00198 unsigned int m_ImageDepth;
00199 unsigned int m_ClusterSize;
00200 LabelType m_ObjectLabel;
00201 unsigned int m_VecDim;
00202 InputPixelType m_LowPoint;
00204 unsigned short *m_Region;
00205 unsigned short *m_RegionCount;
00208 double m_CliqueWeight_1;
00209 double m_CliqueWeight_2;
00210 double m_CliqueWeight_3;
00211 double m_CliqueWeight_4;
00214 void GibbsTotalEnergy(int i);
00215
00217 double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
00218
00219 int Sim(int a, int b);
00220 unsigned int LabelRegion(int i, int l, int change);
00221 void RegionEraser();
00222 void GenerateMediumImage();
00223 void GreyScalarBoundary(LabelledImageIndexType Index3D);
00225 };
00226
00227 }
00228 #ifndef ITK_MANUAL_INSTANTIATION
00229 #include "itkRGBGibbsPriorFilter.txx"
00230 #endif
00231 #endif