NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkUltrasoundPointerCalibrationCostFunction.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkUltrasoundPointerCalibrationCostFunction_h
16 #define niftkUltrasoundPointerCalibrationCostFunction_h
17 
18 #include <itkMultipleValuedCostFunction.h>
19 #include <mitkPointSet.h>
20 #include <vtkSmartPointer.h>
21 #include <vtkMatrix4x4.h>
22 
23 namespace niftk {
24 
29 class UltrasoundPointerCalibrationCostFunction : public itk::MultipleValuedCostFunction
30 {
31 
32 public:
33 
35  typedef itk::MultipleValuedCostFunction Superclass;
36  typedef itk::SmartPointer<Self> Pointer;
37  typedef itk::SmartPointer<const Self> ConstPointer;
38 
39  itkNewMacro( Self );
40 
41  typedef Superclass::ParametersType ParametersType;
42  typedef Superclass::DerivativeType DerivativeType;
43  typedef Superclass::MeasureType MeasureType;
44 
48  virtual unsigned int GetNumberOfValues(void) const override;
49 
53  virtual unsigned int GetNumberOfParameters() const override;
54 
59  virtual void GetDerivative( const ParametersType & parameters, DerivativeType & derivative ) const override;
60 
64  void SetScales(const ParametersType& scales);
65 
69  double GetResidual(const MeasureType& values) const;
70 
74  vtkSmartPointer<vtkMatrix4x4> GetRigidMatrix(const ParametersType & parameters) const;
75 
79  vtkSmartPointer<vtkMatrix4x4> GetScalingMatrix(const ParametersType & parameters) const;
80 
86  virtual MeasureType GetValue( const ParametersType & parameters ) const override;
87 
91  void SetImagePoints(const mitk::PointSet::Pointer imagePoints);
92 
96  void SetSensorPoints(const mitk::PointSet::Pointer sensorPoints);
97 
98 protected:
99 
102 
105  const UltrasoundPointerCalibrationCostFunction&); // Purposefully not impl.
106 
111  void ValidateSizeOfParametersArray(const ParametersType & parameters) const;
112 
117  void ValidateSizeOfScalesArray(const ParametersType & parameters) const;
118 
119 private:
120 
121  unsigned int m_NumberOfParameters;
122  ParametersType m_Scales;
123  mitk::PointSet::Pointer m_ImagePoints;
124  mitk::PointSet::Pointer m_SensorPoints;
125 };
126 
127 } // end namespace
128 
129 #endif
vtkSmartPointer< vtkMatrix4x4 > GetRigidMatrix(const ParametersType &parameters) const
Returns the rigid matrix for the given parameters.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:174
Superclass::ParametersType ParametersType
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:39
Cost function for Ultrasound Pointer based calibration, a la Muratore 2001.
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:29
void ValidateSizeOfScalesArray(const ParametersType &parameters) const
Checks the supplied parameters array is the right size (i.e. it equals this->m_Scales.GetSize()), and throws mitk::Exception if it isnt.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:90
virtual unsigned int GetNumberOfParameters() const override
Required by base class to return the number of parameters.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:46
void SetImagePoints(const mitk::PointSet::Pointer imagePoints)
Sets the points in image space.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:61
virtual void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
Simply uses central differences to approximate the derivative for each of the parameters. See also SetScales where you set the relative size of each parameter step size.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:125
GLboolean GLenum GLenum GLvoid * values
Definition: glew.h:4068
virtual ~UltrasoundPointerCalibrationCostFunction()
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:33
itk::SmartPointer< Self > Pointer
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:36
UltrasoundPointerCalibrationCostFunction & operator=(const UltrasoundPointerCalibrationCostFunction &)
UltrasoundPointerCalibrationCostFunction Self
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:34
double GetResidual(const MeasureType &values) const
Returns the RMS residual of all the values stored in the values array.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:103
itk::SmartPointer< const Self > ConstPointer
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:37
Superclass::DerivativeType DerivativeType
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:42
void SetSensorPoints(const mitk::PointSet::Pointer sensorPoints)
Sets the points in sensor space.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:69
virtual MeasureType GetValue(const ParametersType &parameters) const override
The cost function is the residual error of the reconstructed point, where this function returns an ar...
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:199
itk::MultipleValuedCostFunction Superclass
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:35
Superclass::MeasureType MeasureType
Definition: niftkUltrasoundPointerCalibrationCostFunction.h:43
UltrasoundPointerCalibrationCostFunction()
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:22
virtual unsigned int GetNumberOfValues(void) const override
Equal to the number of points * 3.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:39
void SetScales(const ParametersType &scales)
Used when calculating derivative using central differences.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:53
void ValidateSizeOfParametersArray(const ParametersType &parameters) const
Checks the supplied parameters array is the right size (i.e. it equals this->GetNumberOfParameters())...
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:77
vtkSmartPointer< vtkMatrix4x4 > GetScalingMatrix(const ParametersType &parameters) const
Returns the scaling matrix for the given parameters.
Definition: niftkUltrasoundPointerCalibrationCostFunction.cxx:188
Definition: niftkExceptionObject.h:21