ITK  5.4.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
455 r.Fill(1);
456
457 m_SegmentationFunction->Initialize(r);
458 this->SetDifferenceFunction(m_SegmentationFunction);
459 this->Modified();
460 }
461
462 virtual SegmentationFunctionType *
464 {
465 return m_SegmentationFunction;
466 }
467
472 void
474 {
475 if (n != m_SegmentationFunction->GetMaximumCurvatureTimeStep())
476 {
477 m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
478 this->Modified();
479 }
480 }
483 double
485 {
486 return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
487 }
488
493 void
495 {
496 if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep())
497 {
498 m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
499 this->Modified();
500 }
501 }
504 double
506 {
507 return m_SegmentationFunction->GetMaximumPropagationTimeStep();
508 }
509
513 void
515
519 void
521
522#ifdef ITK_USE_CONCEPT_CHECKING
523 // Begin concept checking
524 itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<TOutputPixelType>));
525 // End concept checking
526#endif
527
528protected:
531
532 void
533 PrintSelf(std::ostream & os, Indent indent) const override;
534
536 void
538 {
539 Superclass::InitializeIteration();
540 // Estimate the progress of the filter
541 this->UpdateProgress(static_cast<float>(this->GetElapsedIterations()) /
542 static_cast<float>(this->GetNumberOfIterations()));
543 }
548 void
549 GenerateData() override;
550
553 bool m_ReverseExpansionDirection{};
554
559 bool m_AutoGenerateSpeedAdvection{};
560
561private:
562 SegmentationFunctionType * m_SegmentationFunction{};
563};
564} // end namespace itk
565
566#ifndef ITK_MANUAL_INSTANTIATION
567# include "itkSegmentationLevelSetImageFilter.hxx"
568#endif
569
570#endif
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
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.
void Initialize(const RadiusType &r) override
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:737
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....