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
115 itkGetConstMacro(TrainingImage, TrainingImageType);
117
119 void
121
125 {
126 return m_LabelledImage;
127 }
128
130 void
131 SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
132
133
136 itkSetMacro(ClusterSize, unsigned int);
137 itkGetConstMacro(ClusterSize, unsigned int);
139
142 itkSetMacro(ObjectLabel, LabelType);
143 itkGetConstMacro(ObjectLabel, LabelType);
145
147 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
148
149 itkSetMacro(StartPoint, IndexType);
150 itkGetConstMacro(StartPoint, IndexType);
151
152 itkSetMacro(BoundaryGradient, unsigned int);
153 itkGetConstMacro(BoundaryGradient, unsigned int);
154
155 itkSetMacro(ObjectThreshold, double);
156 itkGetConstMacro(ObjectThreshold, double);
157
160 itkSetMacro(CliqueWeight_1, double);
161 itkGetConstMacro(CliqueWeight_1, double);
162 itkSetMacro(CliqueWeight_2, double);
163 itkGetConstMacro(CliqueWeight_2, double);
164 itkSetMacro(CliqueWeight_3, double);
165 itkGetConstMacro(CliqueWeight_3, double);
166 itkSetMacro(CliqueWeight_4, double);
167 itkGetConstMacro(CliqueWeight_4, double);
168 itkSetMacro(CliqueWeight_5, double);
169 itkGetConstMacro(CliqueWeight_5, double);
170 itkSetMacro(CliqueWeight_6, double);
171 itkGetConstMacro(CliqueWeight_6, double);
173
175 using MatrixType = vnl_matrix<double>;
176
177protected:
179 ~RGBGibbsPriorFilter() override = default;
180 void
181 PrintSelf(std::ostream & os, Indent indent) const override;
182
184 void
186
187 void
189
190 void
191 GenerateData() override;
192
193 virtual void
195
196 virtual void
198
199 static_assert(InputImageType::ImageDimension == ClassifiedImageType::ImageDimension);
200 static_assert(InputImageType::ImageDimension == 3);
201
202private:
203 using InputImageSizeType = typename TInputImage::SizeType;
204
207
210
213
215
217 unsigned int m_BoundaryGradient{ 7 };
218
220 double m_BoundaryWeight{ 1 };
221
224
226 int m_StartRadius{ 10 };
227
230
232 std::unique_ptr<LabelType[]> m_LabelStatus{ nullptr };
233
236
238 unsigned int m_Temp{ 0 };
239
242
244 unsigned int m_ImageWidth{ 0 };
245
247 unsigned int m_ImageHeight{ 0 };
248
250 unsigned int m_ImageDepth{ 0 };
251
253 unsigned int m_ClusterSize{ 10 };
254
257
259 unsigned int m_VecDim{ 0 };
260
263
265 std::unique_ptr<unsigned short[]> m_Region{ nullptr };
266
268 std::unique_ptr<unsigned short[]> m_RegionCount{ nullptr };
269
270 // Weights for different clique configurations.
271
273 double m_CliqueWeight_1{ 0.0 };
274
276 double m_CliqueWeight_2{ 0.0 };
277
279 double m_CliqueWeight_3{ 0.0 };
280
282 double m_CliqueWeight_4{ 0.0 };
283
285 double m_CliqueWeight_5{ 0.0 };
286
288 double m_CliqueWeight_6{ 0.0 };
289
292 void
294
296 double
297 GibbsEnergy(unsigned int i, unsigned int k, unsigned int k1);
298
300 int
301 Sim(int a, int b);
302
304 unsigned int
305 LabelRegion(int i, int l, int change);
306
309 void
311
313 void
315
318 void
320
321 double m_ObjectThreshold{ 5.0 };
322};
323} // end namespace itk
324#ifndef ITK_MANUAL_INSTANTIATION
325# include "itkRGBGibbsPriorFilter.hxx"
326#endif
327#endif
Base class for the ImageClassifierBase object.
Control indentation during Print() invocation.
Definition itkIndent.h:53
ImageRegionIterator< TClassifiedImage > LabelledImageRegionIterator
ImageRegionConstIterator< TInputImage > InputImageRegionConstIterator
typename LabelledImageIndexType::IndexValueType IndexValueType
ImageRegionIterator< TInputImage > InputImageRegionIterator
typename TClassifiedImage::PixelType LabelledImagePixelType
typename TInputImage::PixelType InputImagePixelType
ImageClassifierBase< TInputImage, TClassifiedImage > ClassifierType
~RGBGibbsPriorFilter() override=default
MRFImageFilter< TInputImage, TClassifiedImage > Superclass
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 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
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.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
#define itkSetMacro(name, type)