ITK  6.0.0
Insight Toolkit
itkSparseFieldFourthOrderLevelSetImageFilter.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 itkSparseFieldFourthOrderLevelSetImageFilter_h
19#define itkSparseFieldFourthOrderLevelSetImageFilter_h
20
25#include <cmath>
26
27namespace itk
28{
37template <typename TImageType>
38class ITK_TEMPLATE_EXPORT NormalBandNode
39{
40public:
41
43 using LevelSetImageType = TImageType;
44
46 using NodeValueType = typename LevelSetImageType::PixelType;
47
50
53
56
59
62
65 NodeDataType m_ManifoldNormal[TImageType::ImageDimension];
66
68 NodeDataType m_Flux[TImageType::ImageDimension];
69
73
77
80
84};
85
153template <typename TInputImage, typename TOutputImage>
155 : public SparseFieldLevelSetImageFilter<TInputImage, TOutputImage>
156{
157public:
158 ITK_DISALLOW_COPY_AND_MOVE(SparseFieldFourthOrderLevelSetImageFilter);
166
168 itkOverrideGetNameOfClassMacro(SparseFieldFourthOrderLevelSetImageFilter);
169
171 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
172
174 using typename Superclass::OutputImageType;
175 using typename Superclass::ValueType;
176 using typename Superclass::IndexType;
177 using typename Superclass::LayerType;
178 using typename Superclass::RadiusType;
179 using typename Superclass::NeighborhoodScalesType;
180
184
187
190
193
196
199
201 // using RadiusType = typename NormalVectorFunctionType::RadiusType;
202
205
206 itkGetConstReferenceMacro(MaxRefitIteration, unsigned int);
207 itkSetMacro(MaxRefitIteration, unsigned int);
208 itkGetConstReferenceMacro(MaxNormalIteration, unsigned int);
209 itkSetMacro(MaxNormalIteration, unsigned int);
210 itkGetConstReferenceMacro(CurvatureBandWidth, ValueType);
211 itkSetMacro(CurvatureBandWidth, ValueType);
212 itkGetConstReferenceMacro(RMSChangeNormalProcessTrigger, ValueType);
213 itkSetMacro(RMSChangeNormalProcessTrigger, ValueType);
214 itkGetConstReferenceMacro(NormalProcessType, int);
215 itkSetMacro(NormalProcessType, int);
216 itkGetConstReferenceMacro(NormalProcessConductance, ValueType);
217 itkSetMacro(NormalProcessConductance, ValueType);
218 itkSetMacro(NormalProcessUnsharpFlag, bool);
219 itkGetConstReferenceMacro(NormalProcessUnsharpFlag, bool);
220 itkBooleanMacro(NormalProcessUnsharpFlag);
221 itkSetMacro(NormalProcessUnsharpWeight, ValueType);
222 itkGetConstReferenceMacro(NormalProcessUnsharpWeight, ValueType);
223
226 void
228
232 unsigned int
234 {
235 return static_cast<int>(std::ceil(m_CurvatureBandWidth + Self::ImageDimension));
236 }
237
240 void
241 SetNumberOfLayers(const unsigned int n) override
242 {
243 unsigned int nm = std::max(this->GetMinimumNumberOfLayers(), n);
244
245 if (nm != this->GetNumberOfLayers())
246 {
247 Superclass::SetNumberOfLayers(nm);
248 this->Modified();
249 }
250 }
251
254 void
256 {
257 Superclass::InitializeIteration();
258 ValueType rmschange = this->GetRMSChange();
261 if ((this->GetElapsedIterations() == 0) || (m_RefitIteration == m_MaxRefitIteration) ||
262 (rmschange <= m_RMSChangeNormalProcessTrigger) || (this->ActiveLayerCheckBand()))
263 {
264 if ((this->GetElapsedIterations() != 0) && (rmschange <= m_RMSChangeNormalProcessTrigger) &&
265 (m_RefitIteration <= 1))
266 {
267 m_ConvergenceFlag = true;
268 }
269
270 m_RefitIteration = 0;
271 ProcessNormals();
272 }
273
274 ++m_RefitIteration;
275 }
276
277#ifdef ITK_USE_CONCEPT_CHECKING
278 // Begin concept checking
279 itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<ValueType>));
280 // End concept checking
281#endif
282
283protected:
286 void
287 PrintSelf(std::ostream & os, Indent indent) const override;
288
293
297 void
298 ComputeCurvatureTarget(const OutputImageType * distanceImage, SparseImageType * sparseImage) const;
299
301 void
303
308 bool
310
311private:
314 unsigned int m_RefitIteration{};
315
319 unsigned int m_MaxRefitIteration{};
320
323 unsigned int m_MaxNormalIteration{};
324
328 ValueType m_RMSChangeNormalProcessTrigger{};
329
332 bool m_ConvergenceFlag{};
333
336 LevelSetFunctionType * m_LevelSetFunction{};
337
342 ValueType m_CurvatureBandWidth{};
343
346 int m_NormalProcessType{};
347
350 ValueType m_NormalProcessConductance{};
351
354 bool m_NormalProcessUnsharpFlag{};
355
358 ValueType m_NormalProcessUnsharpWeight{};
359
362 static const ValueType m_DimConst;
363};
364} // end namespace itk
365
366#ifndef ITK_MANUAL_INSTANTIATION
367# include "itkSparseFieldFourthOrderLevelSetImageFilter.hxx"
368#endif
369
370#endif
Base class for all process objects that output image data.
TOutputImage OutputImageType
This class implements the filter for computing the normal vectors from a scalar implicit function (i....
Control indentation during Print() invocation.
Definition: itkIndent.h:50
This class extends the LevelSetFunction class by adding a grow term based on a target curvature store...
Defines iteration of a local N-dimensional neighborhood of pixels across an itk::Image.
This is a data storage class that can is used as the node type for the SparseImage class.
typename LevelSetImageType::PixelType NodeValueType
typename LevelSetImageType::IndexType IndexType
This class defines all the necessary functionality for performing isotropic and anisotropic diffusion...
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
This class implements the fourth order level set PDE framework.
void PrintSelf(std::ostream &os, Indent indent) const override
~SparseFieldFourthOrderLevelSetImageFilter() override=default
void SetLevelSetFunction(LevelSetFunctionType *lsf)
ValueType ComputeCurvatureFromSparseImageNeighborhood(SparseImageIteratorType &it) const
void ComputeCurvatureTarget(const OutputImageType *distanceImage, SparseImageType *sparseImage) const
This class implements a finite difference partial differential equation solver for evolving surfaces ...
typename OutputImageType::ValueType ValueType
A storage type for sparse image data.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86