ITK  6.0.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 * https://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#include <memory> // For unique_ptr.
27
28namespace itk
29{
55template <typename TInputImage, typename TClassifiedImage>
56class ITK_TEMPLATE_EXPORT RGBGibbsPriorFilter : public MRFImageFilter<TInputImage, TClassifiedImage>
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(RGBGibbsPriorFilter);
60
66
68 itkNewMacro(Self);
69
71 itkOverrideGetNameOfClassMacro(RGBGibbsPriorFilter);
72
74 using typename Superclass::InputImagePixelType;
75 using typename Superclass::InputImageRegionConstIterator;
76 using typename Superclass::InputImageRegionIterator;
77 using typename Superclass::LabelledImageRegionIterator;
78 using typename Superclass::LabelledImagePixelType;
79 using typename Superclass::IndexValueType;
80
82 using InputImageType = TInputImage;
85
87 using InputPixelType = typename TInputImage::PixelType;
88
90 using ClassifiedImageType = TClassifiedImage;
92
96
99
103 using LabelType = unsigned int;
104
107
109 using InputImageVecType = typename TInputImage::PixelType;
111
113 itkSetMacro(TrainingImage, TrainingImageType);
114 itkGetConstMacro(TrainingImage, TrainingImageType);
118 void
120
124 {
125 return m_LabelledImage;
126 }
127
129 void
130 SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
131
133 void
134 SetNumberOfClasses(const unsigned int numberOfClasses) override
135 {
136 itkDebugMacro("setting NumberOfClasses to " << numberOfClasses);
137 if (this->m_NumberOfClasses != numberOfClasses)
138 {
139 this->m_NumberOfClasses = numberOfClasses;
140 this->Modified();
141 }
142 }
146 unsigned int
147 GetNumberOfClasses() const override
148 {
149 return this->m_NumberOfClasses;
150 }
151
154 void
155 SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
156 {
157 itkDebugMacro("setting MaximumNumberOfIterations to " << numberOfIterations);
158 if (this->m_MaximumNumberOfIterations != numberOfIterations)
159 {
160 this->m_MaximumNumberOfIterations = numberOfIterations;
161 this->Modified();
162 }
163 }
168 unsigned int
170 {
171 return this->m_MaximumNumberOfIterations;
172 }
173
175 itkSetMacro(ClusterSize, unsigned int);
176 itkGetConstMacro(ClusterSize, unsigned int);
180 itkSetMacro(ObjectLabel, LabelType);
181 itkGetConstMacro(ObjectLabel, LabelType);
185 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
186
187 itkSetMacro(StartPoint, IndexType);
188 itkGetConstMacro(StartPoint, IndexType);
189
190 itkSetMacro(BoundaryGradient, unsigned int);
191 itkGetConstMacro(BoundaryGradient, unsigned int);
192
193 itkSetMacro(ObjectThreshold, double);
194 itkGetConstMacro(ObjectThreshold, double);
195
197 itkSetMacro(CliqueWeight_1, double);
198 itkGetConstMacro(CliqueWeight_1, double);
199 itkSetMacro(CliqueWeight_2, double);
200 itkGetConstMacro(CliqueWeight_2, double);
201 itkSetMacro(CliqueWeight_3, double);
202 itkGetConstMacro(CliqueWeight_3, double);
203 itkSetMacro(CliqueWeight_4, double);
204 itkGetConstMacro(CliqueWeight_4, double);
205 itkSetMacro(CliqueWeight_5, double);
206 itkGetConstMacro(CliqueWeight_5, double);
207 itkSetMacro(CliqueWeight_6, double);
208 itkGetConstMacro(CliqueWeight_6, double);
212 using MatrixType = vnl_matrix<double>;
213
214protected:
216 ~RGBGibbsPriorFilter() override = default;
217 void
218 PrintSelf(std::ostream & os, Indent indent) const override;
219
221 void
223
224 void
226
227 void
228 GenerateData() override;
229
230 virtual void
232
233 virtual void
235
236#ifdef ITK_USE_CONCEPT_CHECKING
237 // Begin concept checking
239 SameDimension,
242 // End concept checking
243#endif
244
245private:
247
250
252 TrainingImageType m_TrainingImage{};
253
255 LabelledImageType m_LabelledImage{};
256
258 unsigned int m_NumberOfClasses{ 0 };
259
261 unsigned int m_MaximumNumberOfIterations{ 10 };
262
263 typename ClassifierType::Pointer m_ClassifierPtr{};
264
266 unsigned int m_BoundaryGradient{ 7 };
267
269 double m_BoundaryWeight{ 1 };
270
272 double m_GibbsPriorWeight{ 1 };
273
275 int m_StartRadius{ 10 };
276
278 int m_RecursiveNumber{ 0 };
279
281 std::unique_ptr<LabelType[]> m_LabelStatus{ nullptr };
282
284 InputImagePointer m_MediumImage{};
285
287 unsigned int m_Temp{ 0 };
288
290 IndexType m_StartPoint{};
291
293 unsigned int m_ImageWidth{ 0 };
294
296 unsigned int m_ImageHeight{ 0 };
297
299 unsigned int m_ImageDepth{ 0 };
300
302 unsigned int m_ClusterSize{ 10 };
303
305 LabelType m_ObjectLabel{ 1 };
306
308 unsigned int m_VecDim{ 0 };
309
311 InputPixelType m_LowPoint{};
312
314 std::unique_ptr<unsigned short[]> m_Region{ nullptr };
315
317 std::unique_ptr<unsigned short[]> m_RegionCount{ nullptr };
318
319 // Weights for different clique configurations.
320
322 double m_CliqueWeight_1{ 0.0 };
323
325 double m_CliqueWeight_2{ 0.0 };
326
328 double m_CliqueWeight_3{ 0.0 };
329
331 double m_CliqueWeight_4{ 0.0 };
332
334 double m_CliqueWeight_5{ 0.0 };
335
337 double m_CliqueWeight_6{ 0.0 };
338
341 void
343
345 double
346 GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
347
349 int
350 Sim(int a, int b);
351
353 unsigned int
354 LabelRegion(int i, int l, int change);
355
358 void
360
362 void
364
367 void
369
370 double m_ObjectThreshold{ 5.0 };
371};
372} // end namespace itk
373#ifndef ITK_MANUAL_INSTANTIATION
374# include "itkRGBGibbsPriorFilter.hxx"
375#endif
376#endif
Base class for the ImageClassifierBase object.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Implementation of a labeler object that uses Markov Random Fields to classify pixels in an image data...
typename TInputImage::ConstPointer InputImageConstPointer
typename TInputImage::SizeType InputImageSizeType
typename TClassifiedImage::IndexType LabelledImageIndexType
typename TInputImage::Pointer InputImagePointer
The RGBGibbsPriorFilter applies Gibbs Prior model for the segmentation of MRF images.
~RGBGibbsPriorFilter() override=default
void SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
typename TInputImage::IndexType IndexType
vnl_matrix< double > MatrixType
void GibbsTotalEnergy(int i)
void GenerateData() override
void SetClassifier(typename ClassifierType::Pointer ptrToClassifier)
typename TInputImage::PixelType InputPixelType
unsigned int GetMaximumNumberOfIterations() const override
void SetNumberOfClasses(const unsigned int numberOfClasses) override
unsigned int LabelRegion(int i, int l, int change)
double GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1)
typename TClassifiedImage::Pointer LabelledImageType
void GreyScalarBoundary(LabelledImageIndexType Index3D)
unsigned int GetNumberOfClasses() const override
LabelledImageType GetLabelledImage()
typename TClassifiedImage::Pointer TrainingImageType
void MinimizeFunctional() override
TClassifiedImage ClassifiedImageType
typename TInputImage::PixelType InputImageVecType
int Sim(int a, int b)
virtual void ApplyGPImageFilter()
void SetLabelledImage(LabelledImageType image)
virtual void ApplyGibbsLabeller()
void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long IndexValueType
Definition: itkIntTypes.h:93