Contrary to rigid tranformations, elastic transformations warp locally the moving image to align it with the
fixed image. The implementation described here relies on the demon's algorithm published by Jean-Pierre Thirion
[1].
This algorithm generates two images:
A displacement image which represents the computed transformation. Each pixel of this image contains two
values: a displacement to apply in the X direction and another to apply in the Y direction on the corresponding pixel
of the moving image to be registered on the fixed image.
The result of the registration of the moving image on the fixed image.
ElasticRegistration2d has two levels of regularization: fluid and elastic. The fluid regularization
corresponds to the force field regularization and the elastic one corresponds to the displacement field
regularization.
The force field is an elementary displacement which is iteratively added to the current displacement
field during the registration procedure. This force field tends to decrease the similarity measurement
between both images.
ElasticRegistration2d also provides a multi-resolution approach which prevents
the optimization procedure from falling into a local extrema and also speeds up the calculation.
The coarsest and the finest resolution levels of the multi-resolution can be user-defined.
The registration is evaluated at the coarsest level first and then iteratively at each level until the finest
one. The higher the finest level, the faster the computation. The lower the finest level, the more
accurate the registration.
(a)
(b)
(c)
Figure 1. Elastic registration by demon's algorithm: (a) the fixed image,
(b) the moving image (artificially distorted image), (c) the moving image registered on the fixed image
This algorithm can notify some information during the processing (pyramid level, number of iterations, energy)
and can be interrupted. These information can be intercepted with the progress data callback function
defined by the setProgressDataCallback function.
In this case, data sent to the callback will be a string containing a JSON structure including
the pyramid level, the number of iterations, and the energy.
Intercepting these events slows down the execution.
More information on the callback functions can be found in the Processing interaction section.
Reference:
[1] J.P.Thirion. Image matching as a diffusion process: an analogy with Maxwell
s demons.
Medical Image Analysis , Elsevier, vol. 2, no. 3, pp. 243
260, 1998
// Output structure of the elasticRegistration2d function.structElasticRegistration2dOutput{/// The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).
std::shared_ptr< iolink::ImageView> outputImage;/// The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).
std::shared_ptr< iolink::ImageView> outputDisplacementField;};// Function prototype ElasticRegistration2dOutput
elasticRegistration2d( std::shared_ptr< iolink::ImageView> inputFixedImage,
std::shared_ptr< iolink::ImageView> inputMovingImage,ElasticRegistration2d::MetricType metricType,double tolerance,
iolink::Vector2u32 pyramidLevels,
iolink::Vector2d elasticStandardDeviation,
iolink::Vector2d fluidStandardDeviation,
std::shared_ptr< iolink::ImageView> outputImage = NULL,
std::shared_ptr< iolink::ImageView> outputDisplacementField = NULL );
/// Output structure of the ElasticRegistration2d function.publicstructElasticRegistration2dOutput{/// /// The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit)./// publicIOLink.ImageView outputImage;/// /// The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit)./// publicIOLink.ImageView outputDisplacementField;};// Function prototype.publicstaticElasticRegistration2dOutputElasticRegistration2d(IOLink.ImageView inputFixedImage,IOLink.ImageView inputMovingImage,ElasticRegistration2d.MetricType metricType =ImageDev.ElasticRegistration2d.MetricType.MEAN_SQUARE_DIFFERENCE,double tolerance =0.025,uint[] pyramidLevels =null,double[] elasticStandardDeviation =null,double[] fluidStandardDeviation =null,IOLink.ImageView outputImage =null,IOLink.ImageView outputDisplacementField =null);
Class Syntax
// Command constructor.ElasticRegistration2d();/// Gets the inputFixedImage parameter./// The input fixed grayscale image on which the moving image has to be registered.
std::shared_ptr< iolink::ImageView> inputFixedImage()const;/// Sets the inputFixedImage parameter./// The input fixed grayscale image on which the moving image has to be registered.void setInputFixedImage( std::shared_ptr< iolink::ImageView> inputFixedImage );/// Gets the inputMovingImage parameter./// The input moving grayscale image to be registered. Its dimensions and type can be different than the moving image input.
std::shared_ptr< iolink::ImageView> inputMovingImage()const;/// Sets the inputMovingImage parameter./// The input moving grayscale image to be registered. Its dimensions and type can be different than the moving image input.void setInputMovingImage( std::shared_ptr< iolink::ImageView> inputMovingImage );/// Gets the metricType parameter./// The type of metric used to measure the similarity/dissimilarity between the fixed and the transformed image.ElasticRegistration2d::MetricType metricType()const;/// Sets the metricType parameter./// The type of metric used to measure the similarity/dissimilarity between the fixed and the transformed image.void setMetricType(constElasticRegistration2d::MetricType& metricType );/// Gets the tolerance parameter./// The maximum relative variation of the metric to stop the process. This variation is recomputed at each iteration.double tolerance()const;/// Sets the tolerance parameter./// The maximum relative variation of the metric to stop the process. This variation is recomputed at each iteration.void setTolerance(constdouble& tolerance );/// Gets the pyramidLevels parameter./// The two-dimensional vector representing the coarsest (resp. finest) resolution level in its first (resp. second) element.
iolink::Vector2u32 pyramidLevels()const;/// Sets the pyramidLevels parameter./// The two-dimensional vector representing the coarsest (resp. finest) resolution level in its first (resp. second) element.void setPyramidLevels(const iolink::Vector2u32& pyramidLevels );/// Gets the elasticStandardDeviation parameter./// The standard deviation of the gaussian kernel used to smooth the displacement field at each iteration.
iolink::Vector2d elasticStandardDeviation()const;/// Sets the elasticStandardDeviation parameter./// The standard deviation of the gaussian kernel used to smooth the displacement field at each iteration.void setElasticStandardDeviation(const iolink::Vector2d& elasticStandardDeviation );/// Gets the fluidStandardDeviation parameter./// The standard deviation of the gaussian kernel used to smooth the forces field at each iteration. This parameter value is critical to reach large displacements.
iolink::Vector2d fluidStandardDeviation()const;/// Sets the fluidStandardDeviation parameter./// The standard deviation of the gaussian kernel used to smooth the forces field at each iteration. This parameter value is critical to reach large displacements.void setFluidStandardDeviation(const iolink::Vector2d& fluidStandardDeviation );/// Gets the outputImage parameter./// The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).
std::shared_ptr< iolink::ImageView> outputImage()const;/// Sets the outputImage parameter./// The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).void setOutputImage( std::shared_ptr< iolink::ImageView> outputImage );/// Gets the outputDisplacementField parameter./// The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).
std::shared_ptr< iolink::ImageView> outputDisplacementField()const;/// Sets the outputDisplacementField parameter./// The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).void setOutputDisplacementField( std::shared_ptr< iolink::ImageView> outputDisplacementField );// Method to launch the command.void execute();
# Property of the inputFixedImage parameter.ElasticRegistration2d.input_fixed_image
# Property of the inputMovingImage parameter.ElasticRegistration2d.input_moving_image
# Property of the metricType parameter.ElasticRegistration2d.metric_type
# Property of the tolerance parameter.ElasticRegistration2d.tolerance
# Property of the pyramidLevels parameter.ElasticRegistration2d.pyramid_levels
# Property of the elasticStandardDeviation parameter.ElasticRegistration2d.elastic_standard_deviation
# Property of the fluidStandardDeviation parameter.ElasticRegistration2d.fluid_standard_deviation
# Property of the outputImage parameter.ElasticRegistration2d.output_image
# Property of the outputDisplacementField parameter.ElasticRegistration2d.output_displacement_field
// Method to launch the command.
execute()
// Command constructor.ElasticRegistration2d()// Property of the inputFixedImage parameter.ElasticRegistration2d.inputFixedImage
// Property of the inputMovingImage parameter.ElasticRegistration2d.inputMovingImage
// Property of the metricType parameter.ElasticRegistration2d.metricType
// Property of the tolerance parameter.ElasticRegistration2d.tolerance
// Property of the pyramidLevels parameter.ElasticRegistration2d.pyramidLevels
// Property of the elasticStandardDeviation parameter.ElasticRegistration2d.elasticStandardDeviation
// Property of the fluidStandardDeviation parameter.ElasticRegistration2d.fluidStandardDeviation
// Property of the outputImage parameter.ElasticRegistration2d.outputImage
// Property of the outputDisplacementField parameter.ElasticRegistration2d.outputDisplacementField
// Method to launch the command.Execute()
Parameters
Parameter Name
Description
Type
Supported Values
Default Value
inputFixedImage
The input fixed grayscale image on which the moving image has to be registered.
Image
Grayscale
nullptr
inputMovingImage
The input moving grayscale image to be registered. Its dimensions and type can be different than the moving image input.
Image
Grayscale
nullptr
metricType
The type of metric used to measure the similarity/dissimilarity between the fixed and the transformed image.
MEAN_SQUARE_DIFFERENCE
The metric used is the Mean Squared Difference, it has to be minimized.
CORRELATION
The metric used is the Normalized Correlation, it has to be maximized.
Enumeration
MEAN_SQUARE_DIFFERENCE
tolerance
The maximum relative variation of the metric to stop the process. This variation is recomputed at each iteration.
Float64
>0
0.025
pyramidLevels
The two-dimensional vector representing the coarsest (resp. finest) resolution level in its first (resp. second) element.
A value of 0 corresponds to the full resolution and a value of N corresponds to a resolution
of 12N.
Vector2u32
Any value
{2, 0}
elasticStandardDeviation
The standard deviation of the gaussian kernel used to smooth the displacement field at each iteration.
Vector2d
>0
{10.f, 10.f}
fluidStandardDeviation
The standard deviation of the gaussian kernel used to smooth the forces field at each iteration. This parameter value is critical to reach large displacements.
Vector2d
>0
{10.f, 10.f}
outputImage
The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).
Image
nullptr
outputDisplacementField
The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).
Image
nullptr
Parameter Name
Description
Type
Supported Values
Default Value
input_fixed_image
The input fixed grayscale image on which the moving image has to be registered.
image
Grayscale
None
input_moving_image
The input moving grayscale image to be registered. Its dimensions and type can be different than the moving image input.
image
Grayscale
None
metric_type
The type of metric used to measure the similarity/dissimilarity between the fixed and the transformed image.
MEAN_SQUARE_DIFFERENCE
The metric used is the Mean Squared Difference, it has to be minimized.
CORRELATION
The metric used is the Normalized Correlation, it has to be maximized.
enumeration
MEAN_SQUARE_DIFFERENCE
tolerance
The maximum relative variation of the metric to stop the process. This variation is recomputed at each iteration.
float64
>0
0.025
pyramid_levels
The two-dimensional vector representing the coarsest (resp. finest) resolution level in its first (resp. second) element.
A value of 0 corresponds to the full resolution and a value of N corresponds to a resolution
of 12N.
vector2u32
Any value
[2, 0]
elastic_standard_deviation
The standard deviation of the gaussian kernel used to smooth the displacement field at each iteration.
vector2d
>0
[10, 10]
fluid_standard_deviation
The standard deviation of the gaussian kernel used to smooth the forces field at each iteration. This parameter value is critical to reach large displacements.
vector2d
>0
[10, 10]
output_image
The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).
image
None
output_displacement_field
The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).
image
None
Parameter Name
Description
Type
Supported Values
Default Value
inputFixedImage
The input fixed grayscale image on which the moving image has to be registered.
Image
Grayscale
null
inputMovingImage
The input moving grayscale image to be registered. Its dimensions and type can be different than the moving image input.
Image
Grayscale
null
metricType
The type of metric used to measure the similarity/dissimilarity between the fixed and the transformed image.
MEAN_SQUARE_DIFFERENCE
The metric used is the Mean Squared Difference, it has to be minimized.
CORRELATION
The metric used is the Normalized Correlation, it has to be maximized.
Enumeration
MEAN_SQUARE_DIFFERENCE
tolerance
The maximum relative variation of the metric to stop the process. This variation is recomputed at each iteration.
Float64
>0
0.025
pyramidLevels
The two-dimensional vector representing the coarsest (resp. finest) resolution level in its first (resp. second) element.
A value of 0 corresponds to the full resolution and a value of N corresponds to a resolution
of 12N.
Vector2u32
Any value
{2, 0}
elasticStandardDeviation
The standard deviation of the gaussian kernel used to smooth the displacement field at each iteration.
Vector2d
>0
{10f, 10f}
fluidStandardDeviation
The standard deviation of the gaussian kernel used to smooth the forces field at each iteration. This parameter value is critical to reach large displacements.
Vector2d
>0
{10f, 10f}
outputImage
The moving image transformed by the output displacement field. Its dimensions are forced to the same values as the fixed image, its type is forced to floating point precision (32-bit).
Image
null
outputDisplacementField
The displacement field that maps a pixel of the moving image onto the corresponding pixel in the fixed image. Each pixel of the displacement image contains two values: the first one represents the displacement in the X direction and one in the Y direction. Its dimensions are forced to the same values as the moving image, and its type is forced to floating point precision (32-bit).