20 #ifndef MIRTK_LieBracketImageFilter2D_H 21 #define MIRTK_LieBracketImageFilter2D_H 23 #include "mirtk/LieBracketImageFilter.h" 25 #include "mirtk/Matrix.h" 26 #include "mirtk/Parallel.h" 27 #include "mirtk/Profiling.h" 36 template <
class TVoxel>
42 mirtkAttributeMacro(
Matrix, MatW2I);
66 using Superclass::Output;
75 virtual void Run(
double [2],
int,
int);
78 virtual double Run(
int,
int,
int,
int);
87 template <
class VoxelType>
96 template <
class VoxelType>
102 template <
class VoxelType>
105 Superclass::Output(output);
110 template <
class VoxelType>
119 cerr << this->
NameOfClass() <<
"::Initialize: Input images are no 2D vector fields" << endl;
126 template <
class VoxelType>
135 }
else if (i >= v.
X() - 1) {
142 jac(0, 0) = 0.5 * (v(b, j, 0, 0) - v(a, j, 0, 0));
143 jac(1, 0) = 0.5 * (v(b, j, 0, 1) - v(a, j, 0, 1));
148 }
else if (j >= v.
Y() - 1) {
155 jac(0, 1) = 0.5 * (v(i, b, 0, 0) - v(i, a, 0, 0));
156 jac(1, 1) = 0.5 * (v(i, b, 0, 1) - v(i, a, 0, 1));
162 template <
class VoxelType>
165 Matrix lJ(2, 2), rJ(2, 2);
178 return (lJ(t, 0) * rx - lx * rJ(t, 0)) + (lJ(t, 1) * ry - ly * rJ(t, 1));
182 template <
class VoxelType>
185 Matrix lJ(2, 2), rJ(2, 2);
198 vec[0] = (lJ(0, 0) * rx - lx * rJ(0, 0)) + (lJ(0, 1) * ry - ly * rJ(0, 1));
199 vec[1] = (lJ(1, 0) * rx - lx * rJ(1, 0)) + (lJ(1, 1) * ry - ly * rJ(1, 1));
202 namespace LieBracketImageFilter2DUtils {
206 template <
class VoxelType>
214 FilterType *_LieBracketFilter;
220 Run(FilterType *filter, ImageType *output)
222 _LieBracketFilter(filter),
230 for (
int j = r.rows().begin(); j != r.rows().end(); ++j)
231 for (
int i = r.cols().begin(); i != r.cols().end(); ++i) {
232 _LieBracketFilter->
Run(vec, i, j);
233 _Output->PutAsDouble(i, j, 0, 0, vec[0]);
234 _Output->PutAsDouble(i, j, 0, 1, vec[1]);
242 template <
class VoxelType>
248 MIRTK_START_TIMING();
252 MIRTK_DEBUG_TIMING(2,
"LieBracketImageFilter");
258 #endif // MIRTK_LieBracketImageFilter2D_H virtual const ImageType * GetInput(int) const
LieBracketImageFilter2D()
Constructor.
LieBracketImageFilter< TVoxel > Superclass
Type of superclass.
virtual ~LieBracketImageFilter2D()
Destructor.
Run(FilterType *filter, ImageType *output)
Constructor.
virtual void Initialize()
Initialize filter.
const Matrix & GetWorldToImageMatrix() const
Return transformation matrix for world to image coordinates.
GenericImage< VoxelType > ImageType
Input/output image type.
virtual void Output(ImageType *)
Set output.
void Jacobian(Matrix &, const ImageType &, int, int)
Compute 1st order derivatives of given vector field.
int Y() const
Returns the number of voxels in the y-direction.
Parallelizable body of LieBracketImageFilter2D::Run.
TVoxel VoxelType
Input/output image voxel type.
int X() const
Returns the number of voxels in the x-direction.
virtual void Initialize()
Initialize filter.
virtual const char * NameOfClass() const =0
Get name of class, which this object is an instance of.
virtual void Run()
Run filter on every voxel.
void parallel_for(const Range &range, const Body &body)
parallel_for dummy template function which executes the body serially