20 #ifndef MIRTK_BSplineFreeFormTransformationSV_H 21 #define MIRTK_BSplineFreeFormTransformationSV_H 23 #include "mirtk/BSplineFreeFormTransformation3D.h" 25 #include "mirtk/Math.h" 26 #include "mirtk/ImageFunction.h" 27 #include "mirtk/VoxelFunction.h" 28 #include "mirtk/FFDIntegrationMethod.h" 59 mirtkPublicAttributeMacro(
double,
T);
63 mirtkPublicAttributeMacro(
double, TimeUnit);
66 mirtkPublicAttributeMacro(
int, NumberOfSteps);
74 mirtkPublicAttributeMacro(
double, MaxScaledVelocity);
81 mirtkPublicAttributeMacro(
bool, UseDenseBCHGrid);
85 mirtkPublicAttributeMacro(
bool, LieDerivative);
90 mirtkPublicAttributeMacro(
int, NumberOfBCHTerms);
107 double = -1,
double = -1,
double = -1);
111 double,
double,
double);
133 virtual void Subdivide(
bool =
true,
bool =
true,
bool =
true,
bool =
true);
143 virtual void ApproximateDOFs(
const double *,
const double *,
const double *,
const double *,
144 const double *,
const double *,
const double *,
int);
151 const double *,
const double *,
const double *,
int,
152 double *,
double = 1.0)
const;
180 virtual void Interpolate(
const double *,
const double *,
const double *);
211 virtual bool Set(
const char *,
const char *);
224 void Evaluate(
double &,
double &,
double &,
double)
const;
232 double,
double)
const;
236 double,
double,
double)
const;
240 double,
double,
double,
double)
const;
296 template <
class VoxelType>
316 template <
class VoxelType>
332 virtual void LocalTransform(
double &,
double &,
double &,
double = 0,
double = NaN)
const;
335 virtual bool LocalInverse(
double &,
double &,
double &,
double = 0,
double = NaN)
const;
394 virtual void LocalJacobian(
Matrix &,
double,
double,
double,
double = 0,
double = NaN)
const;
397 virtual void LocalHessian(
Matrix [3],
double,
double,
double,
double = 0,
double = NaN)
const;
400 virtual void JacobianDOFs(
Matrix &,
int,
double,
double,
double,
double = 0,
double = NaN)
const;
409 virtual void JacobianDOFs(
double [3],
int,
double,
double,
double,
double = 0,
double = NaN)
const;
423 int cp,
double x,
double y,
double z,
double t = 0,
double t0 = NaN,
424 bool wrt_world =
true,
bool use_spacing =
true)
const;
439 double,
double,
double)
const;
448 double = -1,
double = 1)
const;
453 double *,
double = 0,
double = -1,
double = 1)
const;
477 friend class EvaluateBSplineSVFFD2D;
495 _LogA(logA), _Output(output)
508 v.
_x =
static_cast<T>(_LogA(0, 0) * x + _LogA(0, 1) * y + _LogA(0, 2) * z + _LogA(0, 3));
509 v.
_y =
static_cast<T>(_LogA(1, 0) * x + _LogA(1, 1) * y + _LogA(1, 2) * z + _LogA(1, 3));
510 v.
_z =
static_cast<T>(_LogA(2, 0) * x + _LogA(2, 1) * y + _LogA(2, 2) * z + _LogA(2, 3));
513 template <
class VectorType>
514 void operator()(
int i,
int j,
int k,
int, VectorType *v)
516 double x = i, y = j, z = k;
517 _Output->ImageToWorld(x, y, z);
541 void operator()(
int i,
int j,
int k,
int,
T *out)
543 double x = i, y = j, z = k;
544 _Output->ImageToWorld(x, y, z);
545 out[
_x] =
static_cast<T>(_LogA(0, 0) * x + _LogA(0, 1) * y + _LogA(0, 2) * z + _LogA(0, 3));
546 out[
_y] =
static_cast<T>(_LogA(1, 0) * x + _LogA(1, 1) * y + _LogA(1, 2) * z + _LogA(1, 3));
547 out[
_z] =
static_cast<T>(_LogA(2, 0) * x + _LogA(2, 1) * y + _LogA(2, 2) * z + _LogA(2, 3));
554 static const int _x = 0;
568 _Input(input), _Output(output)
580 v->
_x =
static_cast<T>(vx);
581 v->
_y =
static_cast<T>(vy);
582 v->
_z =
static_cast<T>(vz);
585 template <
class VectorType>
586 void operator()(
int i,
int j,
int k,
int, VectorType *v)
588 double vx = i, vy = j, vz = k;
589 _Output->ImageToWorld (vx, vy, vz);
590 _Input ->WorldToLattice(vx, vy, vz);
591 _Input ->Evaluate (vx, vy, vz);
615 void operator()(
int i,
int j,
int k,
int,
T *out)
617 double x = i, y = j, z = k;
618 _Output->ImageToWorld (x, y, z);
619 _Input ->WorldToLattice(x, y, z);
620 _Input ->Evaluate (x, y, z);
621 out[
_x] =
static_cast<T>(x);
622 out[
_y] =
static_cast<T>(y);
623 out[
_z] =
static_cast<T>(z);
630 static const int _x = 0;
644 _Input(input), _Output(output)
657 v->
_x +=
static_cast<T>(vx);
658 v->
_y +=
static_cast<T>(vy);
659 v->
_z +=
static_cast<T>(vz);
662 template <
class VectorType>
663 void operator()(
int i,
int j,
int k,
int, VectorType *v)
665 double vx = i, vy = j, vz = k;
666 _Output->ImageToWorld (vx, vy, vz);
667 _Input ->WorldToLattice(vx, vy, vz);
668 _Input ->Evaluate (vx, vy, vz);
692 void operator()(
int i,
int j,
int k,
int,
T *out)
694 double x = i, y = j, z = k;
695 _Output->ImageToWorld (x, y, z);
696 _Input ->WorldToLattice(x, y, z);
697 _Input ->Evaluate (x, y, z);
698 out[
_x] +=
static_cast<T>(x);
699 out[
_y] +=
static_cast<T>(y);
700 out[
_z] +=
static_cast<T>(z);
707 static const int _x = 0;
745 Throw(ERR_InvalidArgument, __FUNCTION__,
"Output image must have 3 channels!");
755 Throw(ERR_InvalidArgument, __FUNCTION__,
"Output image must have 3 channels!");
768 return (_IntegrationMethod == FFDIM_SS || _IntegrationMethod == FFDIM_FastSS);
781 return (_TimeUnit > .0) ?
static_cast<int>((abs(T) / _TimeUnit) * _NumberOfSteps + 0.5) : _NumberOfSteps;
787 if (_TimeUnit > .0) nsteps =
static_cast<int>((_TimeUnit / abs(T)) * nsteps + 0.5);
794 if (_NumberOfSteps == 0)
return .0;
795 return ((_TimeUnit > .0) ? (_TimeUnit / static_cast<double>(_NumberOfSteps))
796 : ( abs(T) / static_cast<double>(_NumberOfSteps)));
807 double t0,
double w)
const 815 #endif // MIRTK_BSplineFreeFormTransformationSV_H
Evaluate and add 3D B-spline SV FFD at image voxels.
BaseImage * _Output
Output image.
const ImageAttributes & Attributes() const
Gets the image attributes.
MIRTKCU_API bool IsNaN(double x)
Check if floating point value is not a number (NaN)
Evaluate global SV FFD at image voxels of vector field.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
BaseImage * _Output
Output image.
const BSplineFreeFormTransformationSV * _Input
Input transformation.
Evaluate B-spline SV FFD at image voxels.
const BSplineFreeFormTransformationSV * _Input
Input transformation.
double GetTOrigin() const
Get temporal origin.
FFDIntegrationMethod
Enumeration of implemented numerical integration methods.
Evaluate global SV FFD at image voxels of 3D vector field.
void Throw(ErrorType err, const char *func, Args... args) const
MIRTKCU_API bool AreEqual(double a, double b, double tol=1e-12)
Determine equality of two floating point numbers.
void PutTSize(double)
Set temporal voxel size, i.e., to zero for vector field and non-zero for temporal sequence...
int T() const
Returns the number of voxels in the t-direction.
int NumberOfSpatialVoxels() const
Returns the total number of spatial voxels.
Evaluate B-spline SV FFD at image voxels.
Evaluate and add B-spline SV FFD at image voxels.