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 itkSetMacro(CliqueWeight_5, double);
00156 itkGetMacro(CliqueWeight_5, double);
00157 itkSetMacro(CliqueWeight_6, double);
00158 itkGetMacro(CliqueWeight_6, double);
00159
00160
00162 typedef vnl_matrix<double> MatrixType;
00163
00164 protected:
00165 RGBGibbsPriorFilter();
00166 ~RGBGibbsPriorFilter();
00167 void PrintSelf(std::ostream& os, Indent indent) const;
00168
00169 void Allocate();
00171 virtual void MinimizeFunctional();
00172 virtual void GenerateData();
00173 virtual void ApplyGibbsLabeller();
00174 virtual void ApplyGPImageFilter();
00175
00176
00177 private:
00178 RGBGibbsPriorFilter(const Self&);
00179 void operator=(const Self&);
00180
00181 typedef typename TInputImage::SizeType InputImageSizeType;
00182
00183 InputImageConstPointer m_InputImage;
00184 TrainingImageType m_TrainingImage;
00185 LabelledImageType m_LabelledImage;
00186 unsigned int m_NumberOfClasses;
00187 unsigned int m_MaximumNumberOfIterations;
00188 typename ClassifierType::Pointer m_ClassifierPtr;
00189 unsigned int m_BoundaryGradient;
00190 double m_BoundaryWeight;
00191 double m_GibbsPriorWeight;
00192 int m_StartRadius;
00193 int m_RecursiveNum;
00194 LabelType * m_LabelStatus;
00196 InputImagePointer m_MediumImage;
00198 unsigned int m_Temp;
00199 IndexType m_StartPoint;
00201 unsigned int m_ImageWidth;
00202 unsigned int m_ImageHeight;
00203 unsigned int m_ImageDepth;
00204 unsigned int m_ClusterSize;
00205 LabelType m_ObjectLabel;
00206 unsigned int m_VecDim;
00207 InputPixelType m_LowPoint;
00209 unsigned short *m_Region;
00210 unsigned short *m_RegionCount;
00213 double m_CliqueWeight_1;
00214 double m_CliqueWeight_2;
00215 double m_CliqueWeight_3;
00216 double m_CliqueWeight_4;
00217 double m_CliqueWeight_5;
00218 double m_CliqueWeight_6;
00221 void GibbsTotalEnergy(int i);
00222
00224 double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
00225
00226 int Sim(int a, int b);
00227 unsigned int LabelRegion(int i, int l, int change);
00228 void RegionEraser();
00229 void GenerateMediumImage();
00230 void GreyScalarBoundary(LabelledImageIndexType Index3D);
00232 };
00233
00234 }
00235 #ifndef ITK_MANUAL_INSTANTIATION
00236 #include "itkRGBGibbsPriorFilter.txx"
00237 #endif
00238 #endif