ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkRGBGibbsPriorFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkRGBGibbsPriorFilter_h
19 #define itkRGBGibbsPriorFilter_h
20 
21 #include "vnl/vnl_vector.h"
22 #include "vnl/vnl_matrix.h"
23 
24 #include "itkMRFImageFilter.h"
25 
26 namespace itk
27 {
46 template< typename TInputImage, typename TClassifiedImage >
47 class ITK_TEMPLATE_EXPORT RGBGibbsPriorFilter:public MRFImageFilter< TInputImage,
48  TClassifiedImage >
49 {
50 public:
56 
58  itkNewMacro(Self);
59 
62 
64  typedef typename Superclass::InputImagePixelType InputImagePixelType;
65  typedef typename Superclass::InputImageRegionConstIterator InputImageRegionConstIterator;
66  typedef typename Superclass::InputImageRegionIterator InputImageRegionIterator;
67  typedef typename Superclass::LabelledImageRegionIterator LabelledImageRegionIterator;
68  typedef typename Superclass::LabelledImagePixelType LabelledImagePixelType;
70 
72  typedef TInputImage InputImageType;
73  typedef typename TInputImage::Pointer InputImagePointer;
74  typedef typename TInputImage::ConstPointer InputImageConstPointer;
75 
77  typedef typename TInputImage::PixelType InputPixelType;
78 
80  typedef TClassifiedImage ClassifiedImageType;
81  typedef typename TClassifiedImage::Pointer TrainingImageType;
82 
85  typedef typename TClassifiedImage::Pointer LabelledImageType;
86 
89 
93  typedef unsigned int LabelType;
94 
97 
99  typedef typename TInputImage::PixelType InputImageVecType;
101 
103  void SetTrainingImage(TrainingImageType image);
104 
106  void SetLabelledImage(LabelledImageType LabelledImage);
107 
110  { return m_LabelledImage; }
111 
113  void SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
114 
116  virtual void SetNumberOfClasses( const unsigned int numberOfClasses ) ITK_OVERRIDE
117  {
118  itkDebugMacro("setting NumberOfClasses to " << numberOfClasses );
119  if ( this->m_NumberOfClasses != numberOfClasses )
120  {
121  this->m_NumberOfClasses = numberOfClasses;
122  this->Modified();
123  }
124  }
126 
128  virtual unsigned int GetNumberOfClasses() const ITK_OVERRIDE
129  {
130  return this->m_NumberOfClasses;
131  }
132 
135  virtual void SetMaximumNumberOfIterations( const unsigned int numberOfIterations ) ITK_OVERRIDE
136  {
137  itkDebugMacro("setting MaximumNumberOfIterations to " << numberOfIterations);
138  if ( this->m_MaximumNumberOfIterations != numberOfIterations )
139  {
140  this->m_MaximumNumberOfIterations = numberOfIterations;
141  this->Modified();
142  }
143  }
145 
148  virtual unsigned int GetMaximumNumberOfIterations() const ITK_OVERRIDE
149  {
150  return this->m_MaximumNumberOfIterations;
151  }
152 
154  itkSetMacro(ClusterSize, unsigned int);
155 
157  itkSetMacro(ObjectLabel, LabelType);
158 
160  itkStaticConstMacro(ImageDimension, unsigned int,
161  TInputImage::ImageDimension);
162 
163  itkSetMacro(StartPoint, IndexType);
164 
165  itkSetMacro(BoundaryGradient, unsigned int);
166 
167  itkSetMacro(ObjectThreshold, double);
168 
170  itkSetMacro(CliqueWeight_1, double);
171  itkGetConstMacro(CliqueWeight_1, double);
172  itkSetMacro(CliqueWeight_2, double);
173  itkGetConstMacro(CliqueWeight_2, double);
174  itkSetMacro(CliqueWeight_3, double);
175  itkGetConstMacro(CliqueWeight_3, double);
176  itkSetMacro(CliqueWeight_4, double);
177  itkGetConstMacro(CliqueWeight_4, double);
178  itkSetMacro(CliqueWeight_5, double);
179  itkGetConstMacro(CliqueWeight_5, double);
180  itkSetMacro(CliqueWeight_6, double);
181  itkGetConstMacro(CliqueWeight_6, double);
183 
185  typedef vnl_matrix< double > MatrixType;
186 
187 protected:
189  ~RGBGibbsPriorFilter() ITK_OVERRIDE;
190  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
191 
194  virtual void MinimizeFunctional() ITK_OVERRIDE;
195 
196  virtual void GenerateData() ITK_OVERRIDE;
197 
198  virtual void ApplyGibbsLabeller();
199 
200  virtual void ApplyGPImageFilter();
201 
202 #ifdef ITK_USE_CONCEPT_CHECKING
203  // Begin concept checking
204  itkConceptMacro( SameDimension,
205  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension),
206  itkGetStaticConstMacro(ClassifiedImageType::ImageDimension) > ) );
207  itkConceptMacro( DimensionShouldBe3,
208  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension), 3 > ) );
209  // End concept checking
210 #endif
211 
212 private:
213  RGBGibbsPriorFilter(const Self &);
214  void operator=(const Self &);
215 
217 
233 
255  unsigned int m_ImageHeight;
256  unsigned int m_ImageDepth;
257 
290  void GibbsTotalEnergy(int i);
291 
293  double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
294 
309 };
310 } // end namespace itk
311 #ifndef ITK_MANUAL_INSTANTIATION
312 #include "itkRGBGibbsPriorFilter.hxx"
313 #endif
314 #endif
Light weight base class for most itk classes.
virtual void SetNumberOfClasses(const unsigned int numberOfClasses) override
SmartPointer< Self > Pointer
TClassifiedImage ClassifiedImageType
Superclass::InputImageRegionConstIterator InputImageRegionConstIterator
signed long IndexValueType
Definition: itkIntTypes.h:150
TInputImage::SizeType InputImageSizeType
SmartPointer< const Self > ConstPointer
TClassifiedImage::Pointer LabelledImageType
ClassifierType::Pointer m_ClassifierPtr
TClassifiedImage::IndexType LabelledImageIndexType
Base class for the ImageClassifierBase object.
virtual void SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
Implementation of a labeller object that uses Markov Random Fields to classify pixels in an image dat...
virtual unsigned int GetNumberOfClasses() const override
TInputImage::PixelType InputImageVecType
LabelledImageType GetLabelledImage()
virtual unsigned int GetMaximumNumberOfIterations() const override
TClassifiedImage::Pointer TrainingImageType
TInputImage::IndexType IndexType
Superclass::IndexValueType IndexValueType
TInputImage::Pointer InputImagePointer
Superclass::LabelledImageRegionIterator LabelledImageRegionIterator
Superclass::InputImagePixelType InputImagePixelType
Superclass::LabelledImagePixelType LabelledImagePixelType
The RGBGibbsPriorFilter applies Gibbs Prior model for the segmentation of MRF images.
vnl_matrix< double > MatrixType
TInputImage::ConstPointer InputImageConstPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ImageClassifierBase< TInputImage, TClassifiedImage > ClassifierType
MRFImageFilter< TInputImage, TClassifiedImage > Superclass
Superclass::InputImageRegionIterator InputImageRegionIterator
#define itkConceptMacro(name, concept)
TInputImage::PixelType InputPixelType