ITK  6.0.0
Insight Toolkit
itkSegmentationLevelSetImageFilter.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 itkSegmentationLevelSetImageFilter_h
19#define itkSegmentationLevelSetImageFilter_h
20
23#include "itkMath.h"
24
25namespace itk
26{
143template <typename TInputImage, typename TFeatureImage, typename TOutputPixelType = float>
144class ITK_TEMPLATE_EXPORT SegmentationLevelSetImageFilter
145 : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType, TInputImage::ImageDimension>>
146{
147public:
148 ITK_DISALLOW_COPY_AND_MOVE(SegmentationLevelSetImageFilter);
149
152
153 // static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
154
157
162
164 using typename Superclass::ValueType;
165 using typename Superclass::IndexType;
166 using typename Superclass::TimeStepType;
167 using typename Superclass::InputImageType;
168
170 using FeatureImageType = TFeatureImage;
171
174
178
180 itkOverrideGetNameOfClassMacro(SegmentationLevelSetImageFilter);
181
184 void
185 SetMaximumIterations(unsigned int i)
186 {
187 itkWarningMacro("SetMaximumIterations is deprecated. Please use SetNumberOfIterations instead.");
188 this->SetNumberOfIterations(i);
189 }
192 unsigned int
194 {
195 itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
196 return this->GetNumberOfIterations();
197 }
198
201 virtual void
203 {
204 itkDebugMacro("setting input FeatureImage to " << f);
205 if (f != itkDynamicCastInDebugMode<FeatureImageType *>(this->ProcessObject::GetInput("FeatureImage")))
206 {
207 this->ProcessObject::SetInput("FeatureImage", const_cast<FeatureImageType *>(f));
208 m_SegmentationFunction->SetFeatureImage(f);
209 this->Modified();
210 }
211 }
222 void
224 {
225 this->SetFeatureImage(input);
226 }
227
231 void
233 {
234 m_SegmentationFunction->SetSpeedImage(s);
235 }
236
240 void
242 {
243 m_SegmentationFunction->SetAdvectionImage(v);
244 }
245
248 virtual const SpeedImageType *
250 {
251 return m_SegmentationFunction->GetSpeedImage();
252 }
253
256 virtual const VectorImageType *
258 {
259 return m_SegmentationFunction->GetAdvectionImage();
260 }
261
265 void
267 {
268 itkWarningMacro(
269 << "SetUseNegativeFeaturesOn has been deprecated. Please use ReverseExpansionDirectionOn() instead");
270 this->ReverseExpansionDirectionOn();
271 }
274 void
276 {
277 itkWarningMacro(
278 << "SetUseNegativeFeaturesOff has been deprecated. Please use ReverseExpansionDirectionOff() instead");
279 this->ReverseExpansionDirectionOff();
280 }
281
284 void
286 {
287 itkWarningMacro("SetUseNegativeFeatures has been deprecated. Please use SetReverseExpansionDirection instead");
288 if (u)
289 {
290 this->SetReverseExpansionDirection(false);
291 }
292 else
293 {
294 this->SetReverseExpansionDirection(true);
295 }
296 }
299 bool
301 {
302 itkWarningMacro(
303 << "GetUseNegativeFeatures has been deprecated. Please use GetReverseExpansionDirection() instead");
304 if (m_ReverseExpansionDirection == false)
305 {
306 return true;
307 }
308 else
309 {
310 return false;
311 }
312 }
313
322 itkSetMacro(ReverseExpansionDirection, bool);
323 itkGetConstMacro(ReverseExpansionDirection, bool);
324 itkBooleanMacro(ReverseExpansionDirection);
332 itkSetMacro(AutoGenerateSpeedAdvection, bool);
333 itkGetConstMacro(AutoGenerateSpeedAdvection, bool);
334 itkBooleanMacro(AutoGenerateSpeedAdvection);
341 void
343 {
344 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
345 {
346 this->SetPropagationScaling(v);
347 }
348 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
349 {
350 this->SetAdvectionScaling(v);
351 }
352 }
357 void
359 {
360 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetPropagationWeight()))
361 {
362 m_SegmentationFunction->SetPropagationWeight(v);
363 this->Modified();
364 }
365 }
368 ValueType
370 {
371 return m_SegmentationFunction->GetPropagationWeight();
372 }
373
376 void
378 {
379 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetAdvectionWeight()))
380 {
381 m_SegmentationFunction->SetAdvectionWeight(v);
382 this->Modified();
383 }
384 }
387 ValueType
389 {
390 return m_SegmentationFunction->GetAdvectionWeight();
391 }
392
397 void
399 {
400 if (Math::NotExactlyEquals(v, m_SegmentationFunction->GetCurvatureWeight()))
401 {
402 m_SegmentationFunction->SetCurvatureWeight(v);
403 this->Modified();
404 }
405 }
408 ValueType
410 {
411 return m_SegmentationFunction->GetCurvatureWeight();
412 }
413
415 void
417 {
418 if (m_SegmentationFunction->GetUseMinimalCurvature() != b)
419 {
420 m_SegmentationFunction->SetUseMinimalCurvature(b);
421 this->Modified();
422 }
423 }
426 bool
428 {
429 return m_SegmentationFunction->GetUseMinimalCurvature();
430 }
431
432 void
434 {
435 this->SetUseMinimalCurvature(true);
436 }
437
438 void
440 {
441 this->SetUseMinimalCurvature(false);
442 }
443
449 virtual void
451 {
452 m_SegmentationFunction = s;
453
454 constexpr auto r = MakeFilled<typename SegmentationFunctionType::RadiusType>(1);
455
456 m_SegmentationFunction->Initialize(r);
457 this->SetDifferenceFunction(m_SegmentationFunction);
458 this->Modified();
459 }
460
461 virtual SegmentationFunctionType *
463 {
464 return m_SegmentationFunction;
465 }
466
471 void
473 {
474 if (n != m_SegmentationFunction->GetMaximumCurvatureTimeStep())
475 {
476 m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
477 this->Modified();
478 }
479 }
482 double
484 {
485 return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
486 }
487
492 void
494 {
495 if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep())
496 {
497 m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
498 this->Modified();
499 }
500 }
503 double
505 {
506 return m_SegmentationFunction->GetMaximumPropagationTimeStep();
507 }
508
512 void
514
518 void
520
521#ifdef ITK_USE_CONCEPT_CHECKING
522 // Begin concept checking
523 itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<TOutputPixelType>));
524 // End concept checking
525#endif
526
527protected:
530
531 void
532 PrintSelf(std::ostream & os, Indent indent) const override;
533
535 void
537 {
538 Superclass::InitializeIteration();
539 // Estimate the progress of the filter
540 this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
541 static_cast<float>(this->GetNumberOfIterations()));
542 }
547 void
548 GenerateData() override;
549
552 bool m_ReverseExpansionDirection{};
553
558 bool m_AutoGenerateSpeedAdvection{};
559
560private:
561 SegmentationFunctionType * m_SegmentationFunction{};
562};
563} // end namespace itk
564
565#ifndef ITK_MANUAL_INSTANTIATION
566# include "itkSegmentationLevelSetImageFilter.hxx"
567#endif
568
569#endif
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
A base class which defines the API for implementing a special class of image segmentation filters usi...
typename SegmentationFunctionType::ImageType SpeedImageType
itkGetInputMacro(InitialImage, InputImageType)
virtual const SpeedImageType * GetSpeedImage() const
void PrintSelf(std::ostream &os, Indent indent) const override
typename SegmentationFunctionType::VectorImageType VectorImageType
virtual void SetFeatureImage(const FeatureImageType *f)
virtual const VectorImageType * GetAdvectionImage() const
virtual void SetSegmentationFunction(SegmentationFunctionType *s)
itkGetInputMacro(FeatureImage, FeatureImageType)
virtual SegmentationFunctionType * GetSegmentationFunction()
~SegmentationLevelSetImageFilter() override=default
itkSetInputMacro(InitialImage, InputImageType)
This class implements a finite difference partial differential equation solver for evolving surfaces ...
#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....