Loading...
Searching...
No Matches
itkBSplineSecondOrderDerivativeKernelFunction2.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkBSplineSecondOrderDerivativeKernelFunction2_h
#define itkBSplineSecondOrderDerivativeKernelFunction2_h
#include "itkKernelFunctionBase.h"
#include <vnl/vnl_math.h>
#include <cmath> // For abs.
namespace itk
{
template <unsigned int VSplineOrder = 3>
class ITK_TEMPLATE_EXPORT BSplineSecondOrderDerivativeKernelFunction2 : public KernelFunctionBase<double>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(BSplineSecondOrderDerivativeKernelFunction2);
using Self = BSplineSecondOrderDerivativeKernelFunction2;
using Superclass = KernelFunctionBase<double>;
using Pointer = SmartPointer<Self>;
itkNewMacro(Self);
itkTypeMacro(BSplineSecondOrderDerivativeKernelFunction2, KernelFunctionBase);
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
static double
FastEvaluate(const double u)
{
return Self::Evaluate(Dispatch<VSplineOrder>(), u);
}
static void
FastEvaluate(const double u, double * const weights)
{
Self::Evaluate(Dispatch<VSplineOrder>(), u, weights);
}
double
Evaluate(const double & u) const override
{
return Self::FastEvaluate(u);
}
void
Evaluate(const double u, double * weights) const
{
Self::FastEvaluate(u, weights);
}
protected:
BSplineSecondOrderDerivativeKernelFunction2() = default;
~BSplineSecondOrderDerivativeKernelFunction2() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override
{
Superclass::PrintSelf(os, indent);
os << indent << "Spline Order: " << SplineOrder << std::endl;
}
private:
struct DispatchBase
{};
template <unsigned int>
struct ITK_TEMPLATE_EXPORT Dispatch : DispatchBase
{};
// Second order derivative not defined.
// Second order derivative not defined.
static double
Evaluate(const Dispatch<2> &, const double u)
{
double absValue = std::abs(u);
if (absValue < 0.5)
{
return -2.0;
}
else if (absValue == 0.5)
{
return -0.5;
}
else if (absValue < 1.5)
{
return 1.0;
}
else if (absValue == 1.5)
{
return 0.5;
}
else
{
return 0.0;
}
}
static void
Evaluate(const Dispatch<2> &, const double, double * weights)
{
weights[0] = 1.0;
weights[1] = -2.0;
weights[2] = 1.0;
}
static double
Evaluate(const Dispatch<3> &, const double u)
{
const double absValue = std::abs(u);
if (absValue < 1.0)
{
return vnl_math::sgn0(u) * (3.0 * u) - 2.0;
}
else if (absValue < 2.0)
{
return -vnl_math::sgn(u) * u + 2.0;
}
else
{
return 0.0;
}
}
static void
Evaluate(const Dispatch<3> &, const double u, double * weights)
{
weights[0] = -u + 2.0;
weights[1] = 3.0 * u - 5.0;
weights[2] = -3.0 * u + 4.0;
weights[3] = u - 1.0;
}
static double
Evaluate(const DispatchBase &, const double)
{
itkGenericExceptionMacro("Evaluate not implemented for spline order " << SplineOrder);
}
static void
Evaluate(const DispatchBase &, const double, double *)
{
itkGenericExceptionMacro("Evaluate not implemented for spline order " << SplineOrder);
}
};
} // end namespace itk
#endif
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static void Evaluate(const Dispatch< 3 > &, const double u, double *weights)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:183
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static void Evaluate(const DispatchBase &, const double, double *)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:201
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static double Evaluate(const Dispatch< 2 > &, const double u)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:125
itk::BSplineSecondOrderDerivativeKernelFunction2::itkStaticConstMacro
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder)
itk::BSplineSecondOrderDerivativeKernelFunction2< VSplineOrder >::Superclass
KernelFunctionBase< double > Superclass
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:51
itk::BSplineSecondOrderDerivativeKernelFunction2::FastEvaluate
static void FastEvaluate(const double u, double *const weights)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:75
itk::BSplineSecondOrderDerivativeKernelFunction2::FastEvaluate
static double FastEvaluate(const double u)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:66
itk::BSplineSecondOrderDerivativeKernelFunction2< VSplineOrder >::Self
BSplineSecondOrderDerivativeKernelFunction2 Self
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:50
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static double Evaluate(const Dispatch< 3 > &, const double u)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:163
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static double Evaluate(const DispatchBase &, const double)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:194
itk::BSplineSecondOrderDerivativeKernelFunction2::~BSplineSecondOrderDerivativeKernelFunction2
~BSplineSecondOrderDerivativeKernelFunction2() override=default
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
void Evaluate(const double u, double *weights) const
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:91
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
static void Evaluate(const Dispatch< 2 > &, const double, double *weights)
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:153
itk::BSplineSecondOrderDerivativeKernelFunction2< VSplineOrder >::Pointer
SmartPointer< Self > Pointer
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:52
itk::BSplineSecondOrderDerivativeKernelFunction2::BSplineSecondOrderDerivativeKernelFunction2
BSplineSecondOrderDerivativeKernelFunction2()=default
itk::BSplineSecondOrderDerivativeKernelFunction2::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(BSplineSecondOrderDerivativeKernelFunction2)
itk::BSplineSecondOrderDerivativeKernelFunction2::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:102
itk::BSplineSecondOrderDerivativeKernelFunction2::Evaluate
double Evaluate(const double &u) const override
Definition itkBSplineSecondOrderDerivativeKernelFunction2.h:83
itk
Definition itkAdvancedImageToImageMetric.h:43

Generated on 1768596610 for elastix by 1.15.0 |