ITK  4.4.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< class TInputImage, class TClassifiedImage >
47 class ITK_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 
88  typedef typename TClassifiedImage::IndexType LabelledImageIndexType;
89 
93  typedef unsigned int LabelType;
94 
97 
99  typedef typename TInputImage::PixelType InputImageVecType;
100  typedef typename TInputImage::IndexType IndexType;
101 
103  void SetTrainingImage(TrainingImageType image);
104 
106  void SetLabelledImage(LabelledImageType LabelledImage);
107 
109  LabelledImageType GetLabelledImage()
110  { return m_LabelledImage; }
111 
113  void SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
114 
116  itkSetMacro(NumberOfClasses, unsigned int);
117 
119  itkGetConstMacro(NumberOfClasses, unsigned int);
120 
123  itkSetMacro(MaximumNumberOfIterations, unsigned int);
124 
127  itkGetConstMacro(MaximumNumberOfIterations, unsigned int);
128 
130  itkSetMacro(ClusterSize, unsigned int);
131 
133  itkSetMacro(ObjectLabel, LabelType);
134 
136  itkStaticConstMacro(ImageDimension, unsigned int,
137  TInputImage::ImageDimension);
138 
139  itkSetMacro(StartPoint, IndexType);
140 
141  itkSetMacro(BoundaryGradient, unsigned int);
142 
143  itkSetMacro(ObjectThreshold, double);
144 
146  itkSetMacro(CliqueWeight_1, double);
147  itkGetConstMacro(CliqueWeight_1, double);
148  itkSetMacro(CliqueWeight_2, double);
149  itkGetConstMacro(CliqueWeight_2, double);
150  itkSetMacro(CliqueWeight_3, double);
151  itkGetConstMacro(CliqueWeight_3, double);
152  itkSetMacro(CliqueWeight_4, double);
153  itkGetConstMacro(CliqueWeight_4, double);
154  itkSetMacro(CliqueWeight_5, double);
155  itkGetConstMacro(CliqueWeight_5, double);
156  itkSetMacro(CliqueWeight_6, double);
157  itkGetConstMacro(CliqueWeight_6, double);
159 
161  typedef vnl_matrix< double > MatrixType;
162 
163 protected:
166  void PrintSelf(std::ostream & os, Indent indent) const;
167 
170  virtual void MinimizeFunctional();
171 
172  virtual void GenerateData();
173 
174  virtual void ApplyGibbsLabeller();
175 
176  virtual void ApplyGPImageFilter();
177 
178 #ifdef ITK_USE_CONCEPT_CHECKING
179 
180  itkConceptMacro( SameDimension,
181  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension),
182  itkGetStaticConstMacro(ClassifiedImageType::ImageDimension) > ) );
183  itkConceptMacro( DimensionShouldBe3,
184  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageType::ImageDimension), 3 > ) );
185 
187 #endif
188 
189 private:
190  RGBGibbsPriorFilter(const Self &);
191  void operator=(const Self &);
192 
193  typedef typename TInputImage::SizeType InputImageSizeType;
194 
210 
232  unsigned int m_ImageHeight;
233  unsigned int m_ImageDepth;
234 
267  void GibbsTotalEnergy(int i);
268 
270  double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
271 
286 };
287 } // end namespace itk
288 #ifndef ITK_MANUAL_INSTANTIATION
289 #include "itkRGBGibbsPriorFilter.hxx"
290 #endif
291 #endif
292