Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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 
24  {
25  public:
28 
31 
34 
35  typedef itk::Index<3> IndexType;
36 
38  {};
39 
41 
42  unsigned int GetNumberOfOutputs() const
43  {
44  unsigned int result = 0;
45 
46  if (m_Functor.IsNotNull() && m_ModelParameterizer.IsNotNull())
47  {
48  ParameterizerType::ModelBasePointer tempModel = m_ModelParameterizer->GenerateParameterizedModel();
49  result = m_Functor->GetNumberOfOutputs(tempModel);
50  }
51 
52  return result;
53  }
54 
56  {
57  if (!functor)
58  {
59  itkGenericExceptionMacro( << "Error. Functor is Null.");
60  }
61 
62  m_Functor = functor;
63  }
64 
65  void SetModelParameterizer(const ParameterizerType* parameterizer)
66  {
67  if (!parameterizer)
68  {
69  itkGenericExceptionMacro( << "Error. Parameterizer is Null.");
70  }
71 
72  m_ModelParameterizer = parameterizer;
73  }
74 
75  bool operator!=(const ModelFitFunctorPolicy& other) const
76  {
77  return !(*this == other);
78  }
79 
80  bool operator==(const ModelFitFunctorPolicy& other) const
81  {
82  return (this->m_Functor == other.m_Functor) &&
83  (this->m_ModelParameterizer == other.m_ModelParameterizer);
84  }
85 
87  const IndexType& currentIndex) const
88  {
89  if (!m_Functor)
90  {
91  itkGenericExceptionMacro( << "Error. Cannot process operator(). Functor is Null.");
92  }
93 
94  if (!m_ModelParameterizer)
95  {
96  itkGenericExceptionMacro( << "Error. Cannot process operator(). Parameterizer is Null.");
97  }
98 
99  ParameterizerType::ModelBasePointer parameterizedModel =
100  m_ModelParameterizer->GenerateParameterizedModel(currentIndex);
101  ParameterizerType::ParametersType initialParams = m_ModelParameterizer->GetInitialParameterization(
102  currentIndex);
103  OutputPixelArrayType result = m_Functor->Compute(value, parameterizedModel, initialParams);
104 
105  return result;
106  }
107 
108  private:
109 
110  FunctorConstPointer m_Functor;
111  ParameterizerConstPointer m_ModelParameterizer;
112  };
113 
114 }
115 
116 
117 #endif
mitk::ModelFitFunctorPolicy::SetModelFitFunctor
void SetModelFitFunctor(const mitk::ModelFitFunctorBase *functor)
Definition: mitkModelFitFunctorPolicy.h:55
mitk::ModelFitFunctorPolicy::ParameterizerConstPointer
ParameterizerType::ConstPointer ParameterizerConstPointer
Definition: mitkModelFitFunctorPolicy.h:30
mitk::ModelParameterizerBase
Definition: mitkModelParameterizerBase.h:36
MitkModelFitExports.h
mitk::ModelFitFunctorPolicy::OutputPixelArrayType
ModelFitFunctorBase::InputPixelArrayType OutputPixelArrayType
Definition: mitkModelFitFunctorPolicy.h:27
itk::SmartPointer< const Self >
mitk::ModelFitFunctorPolicy::operator()
OutputPixelArrayType operator()(const InputPixelArrayType &value, const IndexType &currentIndex) const
Definition: mitkModelFitFunctorPolicy.h:86
MITKMODELFIT_EXPORT
#define MITKMODELFIT_EXPORT
Definition: MitkModelFitExports.h:15
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ModelFitFunctorPolicy::FunctorConstPointer
ModelFitFunctorBase::ConstPointer FunctorConstPointer
Definition: mitkModelFitFunctorPolicy.h:33
mitk::ModelParameterizerBase::ParametersType
ModelBaseType::ParametersType ParametersType
Definition: mitkModelParameterizerBase.h:49
mitkModelFitFunctorBase.h
mitk::ModelFitFunctorBase
Definition: mitkModelFitFunctorBase.h:30
mitk::ModelFitFunctorPolicy::~ModelFitFunctorPolicy
~ModelFitFunctorPolicy()
Definition: mitkModelFitFunctorPolicy.h:40
mitk::ModelFitFunctorPolicy::ParameterizerType
mitk::ModelParameterizerBase ParameterizerType
Definition: mitkModelFitFunctorPolicy.h:29
mitk::ModelFitFunctorPolicy::ModelFitFunctorPolicy
ModelFitFunctorPolicy()
Definition: mitkModelFitFunctorPolicy.h:37
mitk::ModelFitFunctorPolicy::SetModelParameterizer
void SetModelParameterizer(const ParameterizerType *parameterizer)
Definition: mitkModelFitFunctorPolicy.h:65
mitk::ModelFitFunctorPolicy::IndexType
itk::Index< 3 > IndexType
Definition: mitkModelFitFunctorPolicy.h:35
mitk::ModelFitFunctorPolicy::operator==
bool operator==(const ModelFitFunctorPolicy &other) const
Definition: mitkModelFitFunctorPolicy.h:80
mitk::ModelFitFunctorBase::InputPixelArrayType
std::vector< ParameterImagePixelType > InputPixelArrayType
Definition: mitkModelFitFunctorBase.h:41
mitk::ModelFitFunctorPolicy::operator!=
bool operator!=(const ModelFitFunctorPolicy &other) const
Definition: mitkModelFitFunctorPolicy.h:75
mitk::ModelFitFunctorPolicy::InputPixelArrayType
ModelFitFunctorBase::InputPixelArrayType InputPixelArrayType
Definition: mitkModelFitFunctorPolicy.h:26
mitk::ModelFitFunctorPolicy
Definition: mitkModelFitFunctorPolicy.h:23
mitk::ModelFitFunctorPolicy::FunctorType
ModelFitFunctorBase FunctorType
Definition: mitkModelFitFunctorPolicy.h:32
mitk::ModelFitFunctorPolicy::GetNumberOfOutputs
unsigned int GetNumberOfOutputs() const
Definition: mitkModelFitFunctorPolicy.h:42