ITK  6.0.0
Insight Toolkit
itkNarrowBandLevelSetImageFilter.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 itkNarrowBandLevelSetImageFilter_h
19#define itkNarrowBandLevelSetImageFilter_h
20
25#include "itkMath.h"
26
27namespace itk
28{
143template <typename TInputImage,
144 typename TFeatureImage,
145 typename TOutputPixelType = float,
146 typename TOutputImage = Image<TOutputPixelType, TInputImage::ImageDimension>>
147class ITK_TEMPLATE_EXPORT NarrowBandLevelSetImageFilter : public NarrowBandImageFilterBase<TInputImage, TOutputImage>
148{
149public:
150 ITK_DISALLOW_COPY_AND_MOVE(NarrowBandLevelSetImageFilter);
151
157
159 using typename Superclass::ValueType;
160 using typename Superclass::IndexType;
161 using typename Superclass::TimeStepType;
162 using typename Superclass::InputImageType;
163
165 using OutputImageType = TOutputImage;
166 using FeatureImageType = TFeatureImage;
167
170
173
175 itkOverrideGetNameOfClassMacro(NarrowBandLevelSetImageFilter);
176
179 virtual void
181 {
182 this->ProcessObject::SetNthInput(1, const_cast<FeatureImageType *>(f));
183 m_SegmentationFunction->SetFeatureImage(f);
184 }
187 virtual FeatureImageType *
189 {
190 return (static_cast<FeatureImageType *>(this->ProcessObject::GetInput(1)));
191 }
192
195 virtual void
197 {
198 this->SetInput(f);
199 }
200
201 virtual const typename SegmentationFunctionType::ImageType *
203 {
204 return m_SegmentationFunction->GetSpeedImage();
205 }
206
207 virtual const typename SegmentationFunctionType::VectorImageType *
209 {
210 return m_SegmentationFunction->GetAdvectionImage();
211 }
212
216 void
218 {
219 itkWarningMacro(
220 << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
221 this->ReverseExpansionDirectionOn();
222 }
225 void
227 {
228 itkWarningMacro(
229 << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
230 this->ReverseExpansionDirectionOff();
231 }
232
235 void
237 {
238 itkWarningMacro("SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
239 if (u)
240 {
241 this->SetReverseExpansionDirection(false);
242 }
243 else
244 {
245 this->SetReverseExpansionDirection(true);
246 }
247 }
250 bool
252 {
253 itkWarningMacro(
254 << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
255 if (this->GetReverseExpansionDirection() == false)
256 {
257 return true;
258 }
259 else
260 {
261 return false;
262 }
263 }
264
273 itkSetMacro(ReverseExpansionDirection, bool);
274 itkGetConstMacro(ReverseExpansionDirection, bool);
275 itkBooleanMacro(ReverseExpansionDirection);
282 void
284 {
285 if (v != m_SegmentationFunction->GetPropagationWeight())
286 {
287 this->SetPropagationScaling(v);
288 }
289 if (v != m_SegmentationFunction->GetAdvectionWeight())
290 {
291 this->SetAdvectionScaling(v);
292 }
293 }
298 void
300 {
301 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
302 {
303 m_SegmentationFunction->SetPropagationWeight(v);
304 }
305 }
308 ValueType
310 {
311 return m_SegmentationFunction->GetPropagationWeight();
312 }
313
316 void
318 {
319 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
320 {
321 m_SegmentationFunction->SetAdvectionWeight(v);
322 }
323 }
326 ValueType
328 {
329 return m_SegmentationFunction->GetAdvectionWeight();
330 }
331
336 void
338 {
339 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
340 {
341 m_SegmentationFunction->SetCurvatureWeight(v);
342 }
343 }
346 ValueType
348 {
349 return m_SegmentationFunction->GetCurvatureWeight();
350 }
351
354 virtual void
356
359 {
360 return m_SegmentationFunction;
361 }
362
365 void
366 SetMaximumIterations(unsigned int i)
367 {
368 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
369 this->SetNumberOfIterations(i);
370 }
373 unsigned int
375 {
376 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
377 return this->GetNumberOfIterations();
378 }
379
380 void
381 SetMaximumRMSError(const double) override
382 {
383 itkWarningMacro("The current implementation of this solver does not compute maximum RMS change. The maximum RMS "
384 "error value will not be set or used.");
385 }
386
387#ifdef ITK_USE_CONCEPT_CHECKING
388 // Begin concept checking
390 // End concept checking
391#endif
392
393protected:
394 ~NarrowBandLevelSetImageFilter() override = default;
396
397 void
398 PrintSelf(std::ostream & os, Indent indent) const override;
399
400
402 void
404 {
405 Superclass::InitializeIteration();
406 // Estimate the progress of the filter
407 this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
408 static_cast<float>(this->GetNumberOfIterations()));
409 }
415 void
417
420 void
421 GenerateData() override;
422
425 bool m_ReverseExpansionDirection{};
426
432
433 typename IsoFilterType::Pointer m_IsoFilter{};
434
435 typename ChamferFilterType::Pointer m_ChamferFilter{};
436
437private:
438 SegmentationFunctionType * m_SegmentationFunction{};
439};
440} // end namespace itk
441
442#ifndef ITK_MANUAL_INSTANTIATION
443# include "itkNarrowBandLevelSetImageFilter.hxx"
444#endif
445
446#endif
This class compute the signed (positive and negative) chamfer distance in a narrow band.
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Compute an approximate distance from an interpolated isocontour to the close grid points.
Light weight base class for most itk classes.
This class implements a multi-threaded finite difference image to image solver that can be applied to...
A base class which defines the API for implementing a special class of image segmentation filters usi...
virtual void SetFeatureImage(const FeatureImageType *f)
virtual const SegmentationFunctionType::ImageType * GetSpeedImage() const
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual const SegmentationFunctionType::VectorImageType * GetAdvectionImage() const
virtual SegmentationFunctionType * GetSegmentationFunction()
typename SegmentationFunctionType::VectorImageType VectorImageType
~NarrowBandLevelSetImageFilter() override=default
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
#define itkConceptMacro(name, concept)
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:733
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....