Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkModelFitFunctorPolicy.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkModelFitFunctorPolicy_h
14 #define mitkModelFitFunctorPolicy_h
15 
16 #include <itkIndex.h>
18 #include <MitkModelFitExports.h>
19 
20 namespace mitk
21 {
22 
34  {
35  public:
38 
41 
44 
45  typedef itk::Index<3> IndexType;
46 
48  {};
49 
51 
52  unsigned int GetNumberOfOutputs() const
53  {
54  unsigned int result = 0;
55 
56  if (m_Functor.IsNotNull() && m_ModelParameterizer.IsNotNull())
57  {
58  ParameterizerType::ModelBasePointer tempModel = m_ModelParameterizer->GenerateParameterizedModel();
59  result = m_Functor->GetNumberOfOutputs(tempModel);
60  }
61 
62  return result;
63  }
64 
66  {
67  if (!functor)
68  {
69  itkGenericExceptionMacro( << "Error. Functor is Null.");
70  }
71 
72  m_Functor = functor;
73  }
74 
75  void SetModelParameterizer(const ParameterizerType* parameterizer)
76  {
77  if (!parameterizer)
78  {
79  itkGenericExceptionMacro( << "Error. Parameterizer is Null.");
80  }
81 
82  m_ModelParameterizer = parameterizer;
83  }
84 
85  bool operator!=(const ModelFitFunctorPolicy& other) const
86  {
87  return !(*this == other);
88  }
89 
90  bool operator==(const ModelFitFunctorPolicy& other) const
91  {
92  return (this->m_Functor == other.m_Functor) &&
93  (this->m_ModelParameterizer == other.m_ModelParameterizer);
94  }
95 
97  const IndexType& currentIndex) const
98  {
99  if (!m_Functor)
100  {
101  itkGenericExceptionMacro( << "Error. Cannot process operator(). Functor is Null.");
102  }
103 
104  if (!m_ModelParameterizer)
105  {
106  itkGenericExceptionMacro( << "Error. Cannot process operator(). Parameterizer is Null.");
107  }
108 
109  ParameterizerType::ModelBasePointer parameterizedModel =
110  m_ModelParameterizer->GenerateParameterizedModel(currentIndex);
111  ParameterizerType::ParametersType initialParams = m_ModelParameterizer->GetInitialParameterization(
112  currentIndex);
113  OutputPixelArrayType result = m_Functor->Compute(value, parameterizedModel, initialParams);
114 
115  return result;
116  }
117 
118  private:
119 
120  FunctorConstPointer m_Functor;
121  ParameterizerConstPointer m_ModelParameterizer;
122  };
123 
124 }
125 
126 
127 #endif
#define MITKMODELFIT_EXPORT
Abstract base class for functors that perform model fitting.
std::vector< ParameterImagePixelType > InputPixelArrayType
Policy class that combines a ModelFitFunctorBase and a ModelParameterizerBase for pixel-wise fitting.
void SetModelFitFunctor(const mitk::ModelFitFunctorBase *functor)
void SetModelParameterizer(const ParameterizerType *parameterizer)
ParameterizerType::ConstPointer ParameterizerConstPointer
bool operator==(const ModelFitFunctorPolicy &other) const
ModelFitFunctorBase::InputPixelArrayType InputPixelArrayType
ModelFitFunctorBase::InputPixelArrayType OutputPixelArrayType
bool operator!=(const ModelFitFunctorPolicy &other) const
mitk::ModelParameterizerBase ParameterizerType
OutputPixelArrayType operator()(const InputPixelArrayType &value, const IndexType &currentIndex) const
ModelFitFunctorBase::ConstPointer FunctorConstPointer
ModelBaseType::ParametersType ParametersType
Find image slices visible on a given plane.