ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkRGBGibbsPriorFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkRGBGibbsPriorFilter_h
00019 #define __itkRGBGibbsPriorFilter_h
00020 
00021 #include "vnl/vnl_vector.h"
00022 #include "vnl/vnl_matrix.h"
00023 
00024 #include "itkMRFImageFilter.h"
00025 
00026 namespace itk
00027 {
00046 template< class TInputImage, class TClassifiedImage >
00047 class ITK_EXPORT RGBGibbsPriorFilter:public MRFImageFilter< TInputImage,
00048                                                             TClassifiedImage >
00049 {
00050 public:
00052   typedef RGBGibbsPriorFilter                             Self;
00053   typedef MRFImageFilter< TInputImage, TClassifiedImage > Superclass;
00054   typedef SmartPointer< Self >                            Pointer;
00055   typedef SmartPointer< const Self >                      ConstPointer;
00056 
00058   itkNewMacro(Self);
00059 
00061   itkTypeMacro(RGBGibbsPriorFilter, MRFImageFilter);
00062 
00064   typedef typename Superclass::InputImagePixelType           InputImagePixelType;
00065   typedef typename Superclass::InputImageRegionConstIterator InputImageRegionConstIterator;
00066   typedef typename Superclass::InputImageRegionIterator      InputImageRegionIterator;
00067   typedef typename Superclass::LabelledImageRegionIterator   LabelledImageRegionIterator;
00068   typedef typename Superclass::LabelledImagePixelType        LabelledImagePixelType;
00069   typedef typename Superclass::IndexValueType                IndexValueType;
00070 
00072   typedef TInputImage                        InputImageType;
00073   typedef typename TInputImage::Pointer      InputImagePointer;
00074   typedef typename TInputImage::ConstPointer InputImageConstPointer;
00075 
00077   typedef typename TInputImage::PixelType InputPixelType;
00078 
00080   typedef TClassifiedImage                   ClassifiedImageType;
00081   typedef typename TClassifiedImage::Pointer TrainingImageType;
00082 
00085   typedef typename TClassifiedImage::Pointer LabelledImageType;
00086 
00088   typedef typename TClassifiedImage::IndexType LabelledImageIndexType;
00089 
00093   typedef unsigned int LabelType;
00094 
00096   typedef ImageClassifierBase< TInputImage, TClassifiedImage > ClassifierType;
00097 
00099   typedef typename TInputImage::PixelType InputImageVecType;
00100   typedef typename TInputImage::IndexType IndexType;
00101 
00103   void SetTrainingImage(TrainingImageType image);
00104 
00106   void SetLabelledImage(LabelledImageType LabelledImage);
00107 
00109   LabelledImageType GetLabelledImage()
00110   { return m_LabelledImage; }
00111 
00113   void SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
00114 
00116   itkSetMacro(NumberOfClasses, unsigned int);
00117 
00119   itkGetConstMacro(NumberOfClasses, unsigned int);
00120 
00123   itkSetMacro(MaximumNumberOfIterations, unsigned int);
00124 
00127   itkGetConstMacro(MaximumNumberOfIterations, unsigned int);
00128 
00130   itkSetMacro(ClusterSize, unsigned int);
00131 
00133   itkSetMacro(ObjectLabel, LabelType);
00134 
00136   itkStaticConstMacro(ImageDimension, unsigned int,
00137                       TInputImage::ImageDimension);
00138 
00139   itkSetMacro(StartPoint, IndexType);
00140 
00141   itkSetMacro(BoundaryGradient, unsigned int);
00142 
00143   itkSetMacro(ObjectThreshold, double);
00144 
00146   itkSetMacro(CliqueWeight_1, double);
00147   itkGetConstMacro(CliqueWeight_1, double);
00148   itkSetMacro(CliqueWeight_2, double);
00149   itkGetConstMacro(CliqueWeight_2, double);
00150   itkSetMacro(CliqueWeight_3, double);
00151   itkGetConstMacro(CliqueWeight_3, double);
00152   itkSetMacro(CliqueWeight_4, double);
00153   itkGetConstMacro(CliqueWeight_4, double);
00154   itkSetMacro(CliqueWeight_5, double);
00155   itkGetConstMacro(CliqueWeight_5, double);
00156   itkSetMacro(CliqueWeight_6, double);
00157   itkGetConstMacro(CliqueWeight_6, double);
00159 
00161   typedef vnl_matrix< double > MatrixType;
00162 protected:
00163   RGBGibbsPriorFilter();
00164   ~RGBGibbsPriorFilter();
00165   void PrintSelf(std::ostream & os, Indent indent) const;
00167 
00170   virtual void MinimizeFunctional();
00171 
00172   virtual void GenerateData();
00173 
00174   virtual void ApplyGibbsLabeller();
00175 
00176   virtual void ApplyGPImageFilter();
00177 
00178 #ifdef ITK_USE_CONCEPT_CHECKING
00179 
00180   itkConceptMacro( SameDimension,
00181                    ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension),
00182                                              itkGetStaticConstMacro(ClassifiedImageType::ImageDimension) > ) );
00183   itkConceptMacro( DimensionShouldBe3,
00184                    ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension), 3 > ) );
00185 
00187 #endif
00188 
00189 
00190 private:
00191   RGBGibbsPriorFilter(const Self &);
00192   void operator=(const Self &);
00193 
00194   typedef typename TInputImage::SizeType InputImageSizeType;
00195 
00210   typename ClassifierType::Pointer m_ClassifierPtr;
00211 
00233   unsigned int   m_ImageHeight;
00234   unsigned int   m_ImageDepth;
00235 
00268   void  GibbsTotalEnergy(int i);
00269 
00271   double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
00272 
00286   double m_ObjectThreshold;
00287 };
00288 } // end namespace itk
00289 #ifndef ITK_MANUAL_INSTANTIATION
00290 #include "itkRGBGibbsPriorFilter.hxx"
00291 #endif
00292 #endif
00293