20 #ifndef MIRTK_LieBracketImageFilter3D_H 21 #define MIRTK_LieBracketImageFilter3D_H 24 #include "mirtk/LieBracketImageFilter.h" 26 #include "mirtk/Matrix.h" 27 #include "mirtk/Parallel.h" 28 #include "mirtk/Profiling.h" 38 template <
class TVoxel>
68 using Superclass::Output;
77 virtual void Run(
double [3],
int,
int,
int);
80 virtual double Run(
int,
int,
int,
int);
89 template <
class VoxelType>
98 template <
class VoxelType>
104 template <
class VoxelType>
107 Superclass::Output(output);
112 template <
class VoxelType>
122 cerr << this->
NameOfClass() <<
"::Initialize: Input images are no 3D vector fields" << endl;
129 template <
class VoxelType>
138 }
else if (i >= v.
GetX()-1) {
145 jac(0, 0) = 0.5 * (v(b, j, k, 0) - v(a, j, k, 0));
146 jac(1, 0) = 0.5 * (v(b, j, k, 1) - v(a, j, k, 1));
147 jac(2, 0) = 0.5 * (v(b, j, k, 2) - v(a, j, k, 2));
152 }
else if (j >= v.
GetY()-1) {
159 jac(0, 1) = 0.5 * (v(i, b, k, 0) - v(i, a, k, 0));
160 jac(1, 1) = 0.5 * (v(i, b, k, 1) - v(i, a, k, 1));
161 jac(2, 1) = 0.5 * (v(i, b, k, 2) - v(i, a, k, 2));
166 }
else if(k >= v.
GetZ()-1) {
173 jac(0, 2) = 0.5 * (v(i, j, b, 0) - v(i, j, a, 0));
174 jac(1, 2) = 0.5 * (v(i, j, b, 1) - v(i, j, a, 1));
175 jac(2, 2) = 0.5 * (v(i, j, b, 2) - v(i, j, a, 2));
181 template <
class VoxelType>
184 Matrix lJ(3, 3), rJ(3, 3);
199 return (lJ(t, 0) * rx - lx * rJ(t, 0)) +
200 (lJ(t, 1) * ry - ly * rJ(t, 1)) +
201 (lJ(t, 2) * rz - lz * rJ(t, 2));
205 template <
class VoxelType>
208 Matrix lJ(3, 3), rJ(3, 3);
223 vec[0] = (lJ(0, 0) * rx - lx * rJ(0, 0)) +
224 (lJ(0, 1) * ry - ly * rJ(0, 1)) +
225 (lJ(0, 2) * rz - lz * rJ(0, 2));
227 vec[1] = (lJ(1, 0) * rx - lx * rJ(1, 0)) +
228 (lJ(1, 1) * ry - ly * rJ(1, 1)) +
229 (lJ(1, 2) * rz - lz * rJ(1, 2));
231 vec[2] = (lJ(2, 0) * rx - lx * rJ(2, 0)) +
232 (lJ(2, 1) * ry - ly * rJ(2, 1)) +
233 (lJ(2, 2) * rz - lz * rJ(2, 2));
236 namespace LieBracketImageFilter3DUtils {
240 template <
class VoxelType>
248 FilterType *_LieBracketFilter;
254 Run(FilterType *filter, ImageType *output)
256 _LieBracketFilter(filter),
264 for (
int k = r.pages().begin(); k != r.pages().end(); ++k)
265 for (
int j = r.rows ().begin(); j != r.rows ().end(); ++j)
266 for (
int i = r.cols ().begin(); i != r.cols ().end(); ++i) {
267 _LieBracketFilter->
Run(vec, i, j, k);
268 _Output->PutAsDouble(i, j, k, 0, vec[0]);
269 _Output->PutAsDouble(i, j, k, 1, vec[1]);
270 _Output->PutAsDouble(i, j, k, 2, vec[2]);
278 template <
class VoxelType>
285 MIRTK_START_TIMING();
289 MIRTK_DEBUG_TIMING(2,
"LieBracketImageFilter");
295 #endif // MIRTK_LieBracketImageFilter3D_H void Jacobian(Matrix &, const ImageType &, int, int, int)
Compute 1st order derivatives of given vector field.
Parallelizable body of LieBracketImageFilter3D::Run.
virtual const ImageType * GetInput(int) const
virtual void Output(ImageType *)
Set output.
Matrix & Ident()
Set to identity matrix.
LieBracketImageFilter3D()
Constructor.
Run(FilterType *filter, ImageType *output)
Constructor.
int GetX() const
Returns the number of voxels in the x-direction.
const Matrix & GetWorldToImageMatrix() const
Return transformation matrix for world to image coordinates.
GenericImage< VoxelType > ImageType
Input/output image type.
int GetY() const
Returns the number of voxels in the y-direction.
virtual void Initialize()
Initialize filter.
virtual void Run()
Run filter on every voxel.
TVoxel VoxelType
Input/output image voxel type.
virtual void Initialize()
Initialize filter.
virtual const char * NameOfClass() const =0
Get name of class, which this object is an instance of.
LieBracketImageFilter< TVoxel > Superclass
Type of superclass of this concrete image filter.
virtual ~LieBracketImageFilter3D()
Destructor.
Matrix _MatW2I
World to image matrix (excluding translation)
int GetZ() const
Returns the number of voxels in the z-direction.
void parallel_for(const Range &range, const Body &body)
parallel_for dummy template function which executes the body serially