ITK  5.2.0
Insight Toolkit
itkRGBGibbsPriorFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
47 template <typename TInputImage, typename TClassifiedImage>
48 class ITK_TEMPLATE_EXPORT RGBGibbsPriorFilter : public MRFImageFilter<TInputImage, TClassifiedImage>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(RGBGibbsPriorFilter);
53 
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(RGBGibbsPriorFilter, MRFImageFilter);
65 
67  using InputImagePixelType = typename Superclass::InputImagePixelType;
68  using InputImageRegionConstIterator = typename Superclass::InputImageRegionConstIterator;
69  using InputImageRegionIterator = typename Superclass::InputImageRegionIterator;
70  using LabelledImageRegionIterator = typename Superclass::LabelledImageRegionIterator;
71  using LabelledImagePixelType = typename Superclass::LabelledImagePixelType;
73 
75  using InputImageType = TInputImage;
76  using InputImagePointer = typename TInputImage::Pointer;
77  using InputImageConstPointer = typename TInputImage::ConstPointer;
78 
80  using InputPixelType = typename TInputImage::PixelType;
81 
83  using ClassifiedImageType = TClassifiedImage;
84  using TrainingImageType = typename TClassifiedImage::Pointer;
85 
88  using LabelledImageType = typename TClassifiedImage::Pointer;
89 
92 
96  using LabelType = unsigned int;
97 
100 
102  using InputImageVecType = typename TInputImage::PixelType;
104 
106  void
107  SetTrainingImage(TrainingImageType image);
108 
110  void
111  SetLabelledImage(LabelledImageType image);
112 
116  {
117  return m_LabelledImage;
118  }
119 
121  void
122  SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
123 
125  void
126  SetNumberOfClasses(const unsigned int numberOfClasses) override
127  {
128  itkDebugMacro("setting NumberOfClasses to " << numberOfClasses);
129  if (this->m_NumberOfClasses != numberOfClasses)
130  {
131  this->m_NumberOfClasses = numberOfClasses;
132  this->Modified();
133  }
134  }
136 
138  unsigned int
139  GetNumberOfClasses() const override
140  {
141  return this->m_NumberOfClasses;
142  }
143 
146  void
147  SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
148  {
149  itkDebugMacro("setting MaximumNumberOfIterations to " << numberOfIterations);
150  if (this->m_MaximumNumberOfIterations != numberOfIterations)
151  {
152  this->m_MaximumNumberOfIterations = numberOfIterations;
153  this->Modified();
154  }
155  }
157 
160  unsigned int
162  {
163  return this->m_MaximumNumberOfIterations;
164  }
165 
167  itkSetMacro(ClusterSize, unsigned int);
168 
170  itkSetMacro(ObjectLabel, LabelType);
171 
173  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
174 
175  itkSetMacro(StartPoint, IndexType);
176 
177  itkSetMacro(BoundaryGradient, unsigned int);
178 
179  itkSetMacro(ObjectThreshold, double);
180 
182  itkSetMacro(CliqueWeight_1, double);
183  itkGetConstMacro(CliqueWeight_1, double);
184  itkSetMacro(CliqueWeight_2, double);
185  itkGetConstMacro(CliqueWeight_2, double);
186  itkSetMacro(CliqueWeight_3, double);
187  itkGetConstMacro(CliqueWeight_3, double);
188  itkSetMacro(CliqueWeight_4, double);
189  itkGetConstMacro(CliqueWeight_4, double);
190  itkSetMacro(CliqueWeight_5, double);
191  itkGetConstMacro(CliqueWeight_5, double);
192  itkSetMacro(CliqueWeight_6, double);
193  itkGetConstMacro(CliqueWeight_6, double);
195 
197  using MatrixType = vnl_matrix<double>;
198 
199 protected:
201  ~RGBGibbsPriorFilter() override;
202  void
203  PrintSelf(std::ostream & os, Indent indent) const override;
204 
205  void
208  void
209  MinimizeFunctional() override;
210 
211  void
212  GenerateData() override;
213 
214  virtual void
215  ApplyGibbsLabeller();
216 
217  virtual void
218  ApplyGPImageFilter();
219 
220 #ifdef ITK_USE_CONCEPT_CHECKING
221  // Begin concept checking
223  SameDimension,
226  // End concept checking
227 #endif
228 
229 private:
231 
247 
269  unsigned int m_ImageHeight{ 0 };
270  unsigned int m_ImageDepth{ 0 };
271 
304  void
305  GibbsTotalEnergy(int i);
306 
308  double
309  GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
310 
311  int
314  unsigned int
318  void
321  void
325  void
329  double m_ObjectThreshold{ 5.0 };
330 };
331 } // end namespace itk
332 #ifndef ITK_MANUAL_INSTANTIATION
333 # include "itkRGBGibbsPriorFilter.hxx"
334 #endif
335 #endif
itk::RGBGibbsPriorFilter::ClassifiedImageType
TClassifiedImage ClassifiedImageType
Definition: itkRGBGibbsPriorFilter.h:83
itk::RGBGibbsPriorFilter::TrainingImageType
typename TClassifiedImage::Pointer TrainingImageType
Definition: itkRGBGibbsPriorFilter.h:84
itk::RGBGibbsPriorFilter::SetMaximumNumberOfIterations
void SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
Definition: itkRGBGibbsPriorFilter.h:147
itk::MRFImageFilter
Implementation of a labeller object that uses Markov Random Fields to classify pixels in an image dat...
Definition: itkMRFImageFilter.h:149
itk::MRFImageFilter::InputImageConstPointer
typename TInputImage::ConstPointer InputImageConstPointer
Definition: itkMRFImageFilter.h:171
itk::RGBGibbsPriorFilter::LabelType
unsigned int LabelType
Definition: itkRGBGibbsPriorFilter.h:96
itk::RGBGibbsPriorFilter::GetNumberOfClasses
unsigned int GetNumberOfClasses() const override
Definition: itkRGBGibbsPriorFilter.h:139
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::RGBGibbsPriorFilter::LabelledImageType
typename TClassifiedImage::Pointer LabelledImageType
Definition: itkRGBGibbsPriorFilter.h:88
itk::SmartPointer< Self >
itk::RGBGibbsPriorFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkRGBGibbsPriorFilter.h:80
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::RGBGibbsPriorFilter::m_ClassifierPtr
ClassifierType::Pointer m_ClassifierPtr
Definition: itkRGBGibbsPriorFilter.h:246
itk::RGBGibbsPriorFilter
The RGBGibbsPriorFilter applies Gibbs Prior model for the segmentation of MRF images.
Definition: itkRGBGibbsPriorFilter.h:48
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::ImageRegionIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionIterator.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::MRFImageFilter::IndexValueType
typename LabelledImageIndexType::IndexValueType IndexValueType
Definition: itkMRFImageFilter.h:206
itk::MRFImageFilter::LabelledImageIndexType
typename TClassifiedImage::IndexType LabelledImageIndexType
Definition: itkMRFImageFilter.h:205
itk::RGBGibbsPriorFilter::GetMaximumNumberOfIterations
unsigned int GetMaximumNumberOfIterations() const override
Definition: itkRGBGibbsPriorFilter.h:161
itk::ImageClassifierBase
Base class for the ImageClassifierBase object.
Definition: itkImageClassifierBase.h:71
itk::MRFImageFilter::InputImageSizeType
typename TInputImage::SizeType InputImageSizeType
Definition: itkMRFImageFilter.h:392
itk::RGBGibbsPriorFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkRGBGibbsPriorFilter.h:103
itkMRFImageFilter.h
itk::MRFImageFilter::InputImagePixelType
typename TInputImage::PixelType InputImagePixelType
Definition: itkMRFImageFilter.h:174
itk::MRFImageFilter::InputImagePointer
typename TInputImage::Pointer InputImagePointer
Definition: itkMRFImageFilter.h:170
itk::RGBGibbsPriorFilter::SetNumberOfClasses
void SetNumberOfClasses(const unsigned int numberOfClasses) override
Definition: itkRGBGibbsPriorFilter.h:126
itk::MRFImageFilter::InputImageType
TInputImage InputImageType
Definition: itkMRFImageFilter.h:169
itk::RGBGibbsPriorFilter::InputImageVecType
typename TInputImage::PixelType InputImageVecType
Definition: itkRGBGibbsPriorFilter.h:102
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::MRFImageFilter::LabelledImagePixelType
typename TClassifiedImage::PixelType LabelledImagePixelType
Definition: itkMRFImageFilter.h:198
itk::ImageRegionConstIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionConstIterator.h:109
itk::RGBGibbsPriorFilter::MatrixType
vnl_matrix< double > MatrixType
Definition: itkRGBGibbsPriorFilter.h:197
itk::RGBGibbsPriorFilter::GetLabelledImage
LabelledImageType GetLabelledImage()
Definition: itkRGBGibbsPriorFilter.h:115