20 #ifndef MIRTK_GenericRegistrationFilter_H 21 #define MIRTK_GenericRegistrationFilter_H 23 #include "mirtk/RegistrationFilter.h" 25 #include "mirtk/Math.h" 26 #include "mirtk/Point.h" 27 #include "mirtk/Vector3D.h" 28 #include "mirtk/EventDelegate.h" 30 #include "mirtk/BaseImage.h" 31 #include "mirtk/GenericImage.h" 32 #include "mirtk/RegisteredImage.h" 33 #include "mirtk/InterpolationMode.h" 34 #include "mirtk/ExtrapolationMode.h" 36 #include "mirtk/SimilarityMeasure.h" 37 #include "mirtk/PointSetDistanceMeasure.h" 38 #include "mirtk/ConstraintMeasure.h" 40 #include "mirtk/LocalOptimizer.h" 41 #include "mirtk/RegistrationEnergy.h" 43 #include "mirtk/Transformation.h" 44 #include "mirtk/TransformationModel.h" 46 #include "mirtk/RegistrationConfig.h" 47 #if MIRTK_Registration_WITH_PointSet 48 # include "vtkSmartPointer.h" 49 # include "vtkPointSet.h" 58 class RegisteredPointSet;
59 class RegistrationEnergyParser;
60 class GenericRegistrationLogger;
61 class GenericRegistrationDebugger;
62 class HomogeneousTransformation;
63 class FreeFormTransformation;
66 const int MAX_NO_RESOLUTIONS = 10;
105 return fequal(_Exponent, other._Exponent, 1e-3);
110 return !(*
this == other);
128 bool IsForwardTransformation()
const 130 return _Exponent > .0;
133 bool IsBackwardTransformation()
const 135 return _Exponent < .0;
138 bool IsIdentity()
const 140 return fequal(_Exponent, .0, 1e-3);
143 operator bool()
const 145 return !IsIdentity();
162 bool IsSymmetric()
const 164 return _TargetTransformation && _SourceTransformation;
181 bool IsSymmetric()
const 183 return _TargetTransformation && _SourceTransformation;
196 int _RefPointSetIndex;
364 #if MIRTK_Registration_WITH_PointSet 367 Array<Array<vtkSmartPointer<vtkPointSet> > >
_PointSet;
372 #else // MIRTK_Registration_WITH_PointSet 380 #endif // MIRTK_Registration_WITH_PointSet 402 Array<DisplacementImageType *> _DisplacementField;
410 virtual int NumberOfFrames(
double * = NULL,
double * = NULL,
double * = NULL)
const;
450 virtual void Reset();
453 virtual void Clear();
527 void Input(vtkPointSet *, vtkPointSet *,
double = .0,
double = 1.0);
532 void Input(
int, vtkPointSet **,
double * = NULL);
537 void AddInput(vtkPointSet *,
double = .0);
579 virtual bool Read(istream &,
bool =
false);
582 virtual bool Set(
const char *,
const char *);
585 virtual bool Set(
const char *,
const char *,
int);
594 virtual void Write(
const char *)
const;
684 template <
class TVoxel>
688 for (
int n = 0; n < num; ++n)
AddInput(image[n]);
694 #endif // MIRTK_GenericRegistrationFilter_H
RegisteredPointSet * OutputPointSet(int, double, TransformationInfo)
void ExtrapolationMode(enum ExtrapolationMode)
Set common/default extrapolation mode for all input images.
string _Name
Name of constraint.
TransformationInfo _TargetTransformation
Target transformation identifier.
virtual void AddPenaltyTerm()
GenericRegistrationFilter()
Constructor.
virtual bool Set(const char *, const char *)
Set named parameter from value as string.
Array< void * > _PointSetOutput
Unused.
Array< DisplacementInfo > _DisplacementInfo
Info of cached displacement fields.
Array< double > _PointSetTime
Unused.
bool IsFixedImage(int) const
Determine whether the specified input image remains untransformed.
int NumberOfImages() const
Number of input images.
struct ImageAttributes _RegistrationDomain
int _SourceIndex
Index of source data set.
EnergyMeasure _Measure
Type of internal forces.
bool _CropPadImages
Whether to crop/pad input images.
double _MaxControlPointSpacing[MAX_NO_RESOLUTIONS][4]
Control point spacing for FFDs.
Array< Vector3D< double > > _Resolution[MAX_NO_RESOLUTIONS]
Image resolution in mm.
virtual void InitializeOutput()
Initialize transformation for sub-registration at current resolution.
TransformationInfo _Transformation
Point set transformation identifier.
bool IsMovingImage(int) const
Determine whether the specified input image will be transformed.
TransformationInfo _SourceTransformation
Source transformation identifier.
virtual void InitializeEnergy()
Initialize registration energy of registration at current resolution.
RegisteredImage::InputImageType ResampledImageType
Type of resolution pyramid images.
int _Centering[MAX_NO_RESOLUTIONS]
Whether to center foreground (if applicable)
virtual struct ImageAttributes RegistrationDomain(int=-1) const
Common attributes of (untransformed) input target data sets at specified resolution level...
RegisteredImage::DisplacementImageType DisplacementImageType
Type of cached displacement field.
MFFDMode
Enumeration of available multi-level transformation modes.
bool AtFinalLevel() const
Whether current level is the final resolution level.
mirtkPublicAttributeMacro(int, NumberOfLevels)
Number of resolution levels.
virtual void AddPointSetConstraintTerm()
virtual void InitializePointSets()
Remesh/-sample input point sets.
Point _SourceOffset
Source origin offset.
TransformationInfo _SourceTransformation
Source transformation identifier.
virtual void InitializeStatus()
Initialize status of transformation parameters.
Array< ResampledImageList > _Image
Resolution pyramid.
Array< ResampledImageType > ResampledImageList
List type storing images for one resolution pyramid level.
int NumberOfPointSets() const
Number of input point sets.
virtual Transformation * OutputTransformation(TransformationInfo)
Get (partial/inverse) output transformation.
Transformation * _Transformation
Current estimate.
virtual void MultiResolutionOptimization()
Run multi-resolution registration.
Structure storing information about cached displacements.
ImageAttributes _Domain
Domain on which it is defined.
EventDelegate _EventDelegate
Forwards optimization events to observers.
enum TransformationModel _CurrentModel
Current transformation model.
Array< void * > _PointSetInput
Unused.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
InterpolationMode DefaultInterpolationMode()
Get default interpolation mode.
Array< enum ExtrapolationMode > _ExtrapolationMode
Extrapolation mode of each input image.
double _InputTime
Time of untransformed data.
bool IsMovingPointSet(int) const
Determine whether the specified input point set will be transformed.
bool _DefaultSign
Whether to use default sign of similarity.
bool IsSourceImage(int) const
string _EnergyFormula
Registration energy formula as string.
Array< ConstraintInfo > _ConstraintInfo
Parsed constraint(s)
virtual Vector3D< double > AverageOutputResolution(int=-1) const
Average resolution of (untransformed) target data sets at given level.
InterpolationMode
Image interpolation modes.
const Transformation * _Transformation
Corresponding transformation instance.
mirtkPublicAggregateMacro(const Transformation, InitialGuess)
Initial guess of optimal transformation.
int _TargetIndex
Index of target data set.
void PreUpdateCallback(bool)
Callback function called by _Energy->Update(bool)
Structure storing information about transformed output point set.
MIRTKCU_API bool fequal(double a, double b, double tol=1e-12)
int _UseGaussianResolutionPyramid
Whether resolution levels correspond to a Gaussian pyramid.
virtual void AddImageSimilarityTerm()
virtual void ApplyInitialGuess()
Initialize transformation parameters using provided initial guess.
TransformationInfo _TargetTransformation
Target transformation identifier.
double _Weight
Weight of constraint.
double _Weight
Weight of similarity term.
Array< PointSetOutputInfo > _PointSetOutputInfo
Unused.
void AddInput(const BaseImage *)
virtual void ParseEnergyFormula(int=-1, int=-1, int=-1)
virtual enum TransformationType TransformationType()
Type of output transformation of sub-registration at current resolution.
ParameterList _Parameter[MAX_NO_RESOLUTIONS]
void Input(const BaseImage *, const BaseImage *)
Set input images of the registration filter.
virtual void Finalize()
Finalize registration at current resolution.
Array< TransformationInfo > _TransformationInfo
Meta-data of partial transformation.
double BackgroundValue(int) const
Get background value of n-th input image (after registration done)
Array< BinaryImage * > _Mask
Domain on which to evaluate similarity.
virtual bool Read(const char *, bool=false)
Read registration parameters from input stream.
int _TargetIndex
Index of target image.
Array< Array< void * > > _PointSet
Unused.
int _CurrentLevel
Current resolution level.
bool IsFixedPointSet(int) const
Determine whether the specified input point set remains untransformed.
bool AtInitialLevel() const
Whether current level is the initial resolution level.
Array< PointSetConstraintInfo > _PointSetConstraintInfo
Unused.
Array< double > _Background
Image background value.
bool IsSourcePointSet(int) const
ResampledImageType::VoxelType VoxelType
Scalar type of resolution pyramid images.
virtual void Run()
Run the multi-level registration.
virtual void TransformationModel(enum TransformationModel)
Set (single) transformation model.
virtual bool Read(istream &, bool=false)
Read registration parameters from input stream.
LocalOptimizer * _Optimizer
Used optimizer.
Array< double > _MinEdgeLength[MAX_NO_RESOLUTIONS]
Minimum edge length in mm.
int _CropPadFFD
Whether to crop/pad FFD lattice.
virtual void GuessParameter()
Point _TargetOffset
Target origin offset.
virtual void Clear()
Reset filter settings and input.
ExtrapolationMode
Image extrapolation modes.
EnergyMeasure
Enumeration of all available energy terms.
int NumberOfRequiredPointSets() const
string _Name
Name of constraint.
virtual void InitializeOptimizer()
Initialize optimizer used to solve registration problem.
virtual Transformation * MakeInitialGuess()
Make an initial guess of the (global) output transformation.
Array< PointSetDistanceInfo > _PointSetDistanceInfo
Unused.
FastDelegate1< bool > PreUpdateFunctionType
Type of pre-update function delegate.
virtual void InitializePyramid()
Initialize image resolution pyramid.
string _Name
Name of polydata distance term.
bool _Subdivide[MAX_NO_RESOLUTIONS][4]
Whether to subdivide FFD.
RegistrationEnergy _Energy
Registration energy.
virtual ParameterList Parameter() const
Get parameter name/value pairs.
int _PointSetIndex
Index of input point set object.
Array< double > _MaxEdgeLength[MAX_NO_RESOLUTIONS]
Maximum edge length in mm.
RegistrationEnergy::PreUpdateFunctionType _PreUpdateDelegate
Delegate of pre-update function.
bool IsTargetImage(int) const
int _SourceIndex
Index of source image.
virtual int NumberOfFrames(double *=NULL, double *=NULL, double *=NULL) const
Determine number of temporal frames and temporal sampling attributes.
Array< enum InterpolationMode > _InterpolationMode
Interpolation mode of each input image.
string _Name
Name of similarity term.
virtual void AddPointSetDistanceTerm()
Array< Point > _Centroid
Centroids of images.
Array< const BaseImage * > _Input
Input images.
void InterpolationMode(enum InterpolationMode)
Set common/default interpolation mode for all input images.
virtual void Write(const char *) const
Write registration parameters to file.
virtual void Reset()
Reset filter settings, but keep input.
SimilarityMeasure _Measure
Type of similarity measure.
double _MinControlPointSpacing[MAX_NO_RESOLUTIONS][4]
Control point spacing for FFDs.
double _DefaultBackground
Default background value.
Array< Transformation * > _TransformationInstance
Partial transformations.
OptimizationMethod
Enumeration of available optimization methods.
bool _DownsampleWithPadding
virtual void Initialize()
Initialize registration at current resolution.
ConstraintMeasure _Measure
Type of constraint.
Array< double > _Blurring[MAX_NO_RESOLUTIONS]
Image blurring value.
PointSetDistanceMeasure _Measure
Measure of polydata distance.
double _Weight
Weight of constraint.
int _DispIndex
Index of cached displacement field.
bool _DefaultSign
Whether to use default sign of distance measure.
TVoxel VoxelType
Voxel type.
virtual void SetInputOf(RegisteredImage *, const struct ImageAttributes &, int, TransformationInfo)
Initialize output image corresponding to registered (transformed) image.
Array< ImageSimilarityInfo > _ImageSimilarityInfo
Parsed similarity measure(s)
virtual ~GenericRegistrationFilter()
Destructor.
int NumberOfRequiredImages() const
double _Weight
Weight of polydata distance term.
virtual ParameterList Parameter() const
Get parameters as key/value as string map.
virtual void InitializeTransformation()
Initialize new transformation instance.
bool IsTargetPointSet(int) const