ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
79 using typename Superclass::IndexValueType;
80
82 using InputImageType = TInputImage;
83 using InputImagePointer = typename TInputImage::Pointer;
84 using InputImageConstPointer = typename TInputImage::ConstPointer;
85
87 using InputPixelType = typename TInputImage::PixelType;
88
90 using ClassifiedImageType = TClassifiedImage;
91 using TrainingImageType = typename TClassifiedImage::Pointer;
92
95 using LabelledImageType = typename TClassifiedImage::Pointer;
96
98 using LabelledImageIndexType = typename TClassifiedImage::IndexType;
99
103 using LabelType = unsigned int;
104
107
109 using InputImageVecType = typename TInputImage::PixelType;
110 using IndexType = typename TInputImage::IndexType;
111
113 itkSetMacro(TrainingImage, TrainingImageType);
114 itkGetConstMacro(TrainingImage, TrainingImageType);
116
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 }
143
144
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 }
164
165
168 unsigned int
170 {
171 return this->m_MaximumNumberOfIterations;
172 }
173
175 itkSetMacro(ClusterSize, unsigned int);
176 itkGetConstMacro(ClusterSize, unsigned int);
178
180 itkSetMacro(ObjectLabel, LabelType);
181 itkGetConstMacro(ObjectLabel, LabelType);
183
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);
210
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
237 SameDimension,
240
241private:
242 using InputImageSizeType = typename TInputImage::SizeType;
243
246
249
252
254 unsigned int m_NumberOfClasses{ 0 };
255
257 unsigned int m_MaximumNumberOfIterations{ 10 };
258
260
262 unsigned int m_BoundaryGradient{ 7 };
263
265 double m_BoundaryWeight{ 1 };
266
269
271 int m_StartRadius{ 10 };
272
275
277 std::unique_ptr<LabelType[]> m_LabelStatus{ nullptr };
278
281
283 unsigned int m_Temp{ 0 };
284
287
289 unsigned int m_ImageWidth{ 0 };
290
292 unsigned int m_ImageHeight{ 0 };
293
295 unsigned int m_ImageDepth{ 0 };
296
298 unsigned int m_ClusterSize{ 10 };
299
302
304 unsigned int m_VecDim{ 0 };
305
308
310 std::unique_ptr<unsigned short[]> m_Region{ nullptr };
311
313 std::unique_ptr<unsigned short[]> m_RegionCount{ nullptr };
314
315 // Weights for different clique configurations.
316
318 double m_CliqueWeight_1{ 0.0 };
319
321 double m_CliqueWeight_2{ 0.0 };
322
324 double m_CliqueWeight_3{ 0.0 };
325
327 double m_CliqueWeight_4{ 0.0 };
328
330 double m_CliqueWeight_5{ 0.0 };
331
333 double m_CliqueWeight_6{ 0.0 };
334
337 void
339
341 double
342 GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
343
345 int
346 Sim(int a, int b);
347
349 unsigned int
350 LabelRegion(int i, int l, int change);
351
354 void
356
358 void
360
363 void
365
366 double m_ObjectThreshold{ 5.0 };
367};
368} // end namespace itk
369#ifndef ITK_MANUAL_INSTANTIATION
370# include "itkRGBGibbsPriorFilter.hxx"
371#endif
372#endif
Base class for the ImageClassifierBase object.
Control indentation during Print() invocation.
Definition itkIndent.h:50
ImageRegionIterator< TClassifiedImage > LabelledImageRegionIterator
ImageRegionConstIterator< TInputImage > InputImageRegionConstIterator
typename LabelledImageIndexType::IndexValueType IndexValueType
ImageRegionIterator< TInputImage > InputImageRegionIterator
typename TClassifiedImage::PixelType LabelledImagePixelType
typename TInputImage::PixelType InputImagePixelType
virtual void Modified() const
ImageClassifierBase< TInputImage, TClassifiedImage > ClassifierType
~RGBGibbsPriorFilter() override=default
MRFImageFilter< TInputImage, TClassifiedImage > Superclass
void SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
typename TInputImage::IndexType IndexType
SmartPointer< const Self > ConstPointer
typename TClassifiedImage::IndexType LabelledImageIndexType
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)
ClassifierType::Pointer m_ClassifierPtr
unsigned int GetNumberOfClasses() const override
static constexpr unsigned int ImageDimension
LabelledImageType GetLabelledImage()
typename TInputImage::Pointer InputImagePointer
typename TClassifiedImage::Pointer TrainingImageType
void MinimizeFunctional() override
InputImageConstPointer m_InputImage
typename TInputImage::SizeType InputImageSizeType
typename TInputImage::PixelType InputImageVecType
int Sim(int a, int b)
typename TInputImage::ConstPointer InputImageConstPointer
std::unique_ptr< unsigned short[]> m_RegionCount
virtual void ApplyGPImageFilter()
void SetLabelledImage(LabelledImageType image)
virtual void ApplyGibbsLabeller()
std::unique_ptr< LabelType[]> m_LabelStatus
void PrintSelf(std::ostream &os, Indent indent) const override
std::unique_ptr< unsigned short[]> m_Region
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....