20 #ifndef MIRTK_MultiLevelStationaryVelocityTransformation_H 21 #define MIRTK_MultiLevelStationaryVelocityTransformation_H 23 #include "mirtk/MultiLevelTransformation.h" 24 #include "mirtk/BSplineFreeFormTransformationSV.h" 26 #include "mirtk/Array.h" 27 #include "mirtk/Matrix.h" 28 #include "mirtk/EventDelegate.h" 29 #include "mirtk/VelocityToDisplacementFieldSS.h" 30 #include "mirtk/VoxelFunction.h" 31 #include "mirtk/Profiling.h" 100 virtual void Put(
int,
double);
112 virtual double Get(
int)
const;
176 template <
class VoxelType>
183 template <
class ScalarType>
187 template <
class VoxelType>
195 template <
class VoxelType>
200 void RKE1(
int,
int,
double &x,
double &y,
double &z,
double t)
const;
206 virtual void Transform(
int,
int,
double &,
double &,
double &,
double = 0,
double = NaN)
const;
209 virtual bool Inverse(
int,
int,
double &,
double &,
double &,
double = 0,
double = NaN)
const;
262 double,
double,
double)
const;
271 double = NaN,
double = 1)
const;
301 _Input(input), _Output(output)
313 v->
_x += vx, v->
_y += vy, v->
_z += vz;
316 template <
class VectorType>
317 void operator()(
int i,
int j,
int k,
int, VectorType *v)
320 _Input->Get(i, j, k, vx, vy, vz);
406 return (svffd ? svffd->IntegrationMethod() == FFDIM_SS ||
407 svffd->IntegrationMethod() == FFDIM_FastSS
416 return (svffd ? svffd->IntegrationMethod() == FFDIM_FastSS :
false);
420 template <
class VoxelType>
425 return (svffd || (svffd->
Z() <= 1 && d.
Z() <= 1) ||
426 (svffd->
Z() > 1 && d.
Z() > 1));
434 return (svffd ? svffd->MaxScaledVelocity() : .0);
445 template <
class VectorType>
449 MIRTK_START_TIMING();
451 const int l1 = (m < 0 ? 0 : m);
454 Array<bool> add_coeff(n,
false);
455 bool convert_to_coeff =
false;
457 for (
int l = l1; l < n; ++l) {
462 if (m < 0 && !_LogA.IsIdentity()) {
464 convert_to_coeff = coeff;
469 for (
int l = l1; l < n; ++l) {
472 convert_to_coeff = coeff;
478 for (
int l = l1; l < n; ++l) {
483 MIRTK_DEBUG_TIMING(3,
"MultiLevelStationaryVelocityTransformation::Velocity");
493 template <
class VoxelType>
500 if (m >= 0 && n == 0)
return;
508 exp.Interpolation(Interpolation_BSpline);
509 exp.ComputeInterpolationCoefficients(
false);
515 exp.Interpolation(Interpolation_Linear);
518 exp.UpperIntegrationLimit(T);
533 ::RKE1(
int m,
int n,
double &x,
double &y,
double &z,
double T)
const 548 const int l1 = (m < 0 ? 0 : m);
549 const double dt = T /
static_cast<double>(N);
550 double xi, yi, zi, vx, vy, vz, dx = .0, dy = .0, dz = .0;
551 for (
int i = 0; i < N; ++i) {
553 xi = x + dx, yi = y + dy, zi = z + dz;
556 dx += (_LogA(0, 0) * xi + _LogA(0, 1) * yi + _LogA(0, 2) * zi + _LogA(0, 3)) * dt;
557 dy += (_LogA(1, 0) * xi + _LogA(1, 1) * yi + _LogA(1, 2) * zi + _LogA(1, 3)) * dt;
558 dz += (_LogA(2, 0) * xi + _LogA(2, 1) * yi + _LogA(2, 2) * zi + _LogA(2, 3)) * dt;
561 for (
int l = l1; l < n; ++l) {
562 vx = xi, vy = yi, vz = zi;
570 x += dx, y += dy, z += dz;
656 #endif // MIRTK_MultiLevelStationaryVelocityTransformation_H
const ImageAttributes & Attributes() const
Gets the image attributes.
void CopyFrom(const VoxelType *)
Copy image data from 1D array.
Add parameters of B-spline SV FFD.
Evaluate global SV FFD at image voxels of vector field.
Status
Enumeration of common states for entities such as objective function parameters.
bool EqualInSpace(const ImageAttributes &attr) const
Whether spatial attributes are equal.
virtual void Initialize()
Initialize a previously allocated image.
void ConvertToCubicBSplineCoefficients(GenericImage< TData > &image, int l)
Convert 3D floating point scalar or vector image to cubic spline coefficients.
virtual void Run()
Compute output = log(input)
BaseImage * _Output
Output image.
const BSplineFreeFormTransformationSV * _Input
Input transformation.
virtual void Input(int, const ImageType *)
Set n-th input (0: velocity field, 1: input displacement field, optional)
int Z() const
Returns the number of voxels in the z-direction.
Evaluate and add B-spline SV FFD at image voxels.