imregister

Intensity-based image registration

Syntax

  • moving_reg = imregister(moving,fixed,transformType,optimizer,metric) example
  • [moving_reg,R_reg] = imregister(moving,Rmoving,fixed,Rfixed,transformType,optimizer,metric)
  • ___ = imregister(___,Name,Value)

Description

example

moving_reg = imregister(moving,fixed,transformType,optimizer,metric) transforms the 2-D or 3-D image, moving, so that it is registered with the reference image, fixed. Both moving and fixed images must be of the same dimensionality, either 2-D or 3-D. transformType is a character string that defines the type of transformation to perform. optimizer is an object that describes the method for optimizing the metric and metric is an object that defines the quantitative measure of similarity between the images to optimize. Returns the aligned image, moving_reg.

[moving_reg,R_reg] = imregister(moving,Rmoving,fixed,Rfixed,transformType,optimizer,metric) transforms the spatially referenced image moving so that it is registered with the spatially referenced image fixed. Rmoving and Rfixed are spatial referencing objects that describe the world coordinate limits and resolution of moving and fixed.

___ = imregister(___,Name,Value) specifies additional options with one or more Name,Value pair arguments.

Examples

expand all

Register Two MRI Images Obtained Using Different Protocols

Read the MRI images.

fixed  = dicomread('knee1.dcm');
moving = dicomread('knee2.dcm');

View the misaligned images.

imshowpair(fixed, moving,'Scaling','joint');

Create a configuration suitable for registering images from the different sensors.

[optimizer, metric] = imregconfig('multimodal')
optimizer = 

  registration.optimizer.OnePlusOneEvolutionary

  Properties:
         GrowthFactor: 1.050000e+00
              Epsilon: 1.500000e-06
        InitialRadius: 6.250000e-03
    MaximumIterations: 100

metric = 

  registration.metric.MattesMutualInformation

  Properties:
    NumberOfSpatialSamples: 500
     NumberOfHistogramBins: 50
              UseAllPixels: 1

Tune the properties of the optimizer to get the problem to converge on a global maxima and to allow for more iterations.

optimizer.InitialRadius = 0.009;
optimizer.Epsilon = 1.5e-4;
optimizer.GrowthFactor = 1.01;
optimizer.MaximumIterations = 300;

Perform the registration.

movingRegistered = imregister(moving, fixed, 'affine', optimizer, metric);

View registered images.

figure
imshowpair(fixed, movingRegistered,'Scaling','joint');

Input Arguments

expand all

moving — Image to be registeredgrayscale image

Image to be registered, specified as a 2-D or 3-D grayscale image.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Rmoving — Spatial referencing information associated with the image to be registeredspatial referencing object

Spatial referencing information associated with image to be registered, specified as a spatial referencing object.

fixed — Reference image in the target orientationgrayscale image

Reference image in the target orientation, specified as a grayscale image.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Rfixed — Spatial referencing information associated with the reference imagespatial referencing object

Spatial referencing information associated with the reference image, specified as a spatial referencing object.

transformType — Geometric transformation to be applied to the image to be registered'translation' | 'rigid' | 'similarity' | 'affine'

Geometric transformation to be applied to the moving image, specified as one of the text strings listed in this table.

Transform TypeDescription
'translation'(x,y) translation.
'rigid'Rigid transformation consisting of translation and rotation.
'similarity'Nonreflective similarity transformation consisting of translation, rotation, and scale.
'affine'Affine transformation consisting of translation, rotation, scale, and shear.

The 'similarity' and 'affine' transformation types always involve nonreflective transformations.

optimizer — Method for optimizing the similarity metricoptimizer object

Method for optimizing the similarity metric, specified as an optimizer object. Use imregconfig to create the optimizer objects registration.optimizer.RegularStepGradientDescent or registration.optimizer.OnePlusOneEvolutionary.

metric — Image similarity metric to be optimized during registrationmetric object

Image similarity metric to be optimized during registration, specified as a metric object. Use imregconfig to create the metric objects registration.metric.MeanSquares or registration.metric.MattesMutualInformation.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'DisplayOptimization',1 enables the verbose optimization mode.

'DisplayOptimization' — Verbose optimization flagfalse (default) | true

Verbose optimization flag, specified as a logical value, either true or false. Controls whether imregister displays optimization information in the command window during the registration process.

Data Types: logical

'InitialTransformation' — Spatial transformation to start ataffine2d or affine3d spatial transformation object

Spatial transformation to start at, specified as an affine2d or affine3d geometric transformation object.

'PyramidLevels' — Number of pyramid levels used during registration process3 (default) | positive integer

Number of pyramid levels used during the registration process, specified as a positive integer.

Example: 'PyramidLevels',4 sets the number of pyramid levels to 4.

Data Types: double

Output Arguments

expand all

moving_reg — Transformed imagenumeric matrix

Transformed image, returned as a matrix. Any fill pixels introduced that do not correspond to locations in the original image are 0.

R_reg — Spatial referencing information associated with output imagespatial referencing object

Spatial referencing information associated with output image, specified as a spatial referencing object.

More About

expand all

Tips

  • Create optimizer and metric with the imregconfig function before calling imregister. Getting good results from optimization-based image registration usually requires modifying optimizer or metric settings for the pair of images being registered. The imregconfig function provides a default configuration that should only be considered a starting point. For example, if you increase the number of iterations in the optimizer, reduce the optimizer step size, or change the number of samples in a stochastic metric, the registration improves to a point, at the expense of performance. See the output of imregconfig for more information on the different parameters that you can modify.

  • If the spatial scaling of your images differs by more than 10%, you should resize them with imresize before registering them.

  • Use imshowpair or imfuse to visualize the results of registration.

  • You can use imregister in an automated workflow to register several images.

  • When you have spatial referencing information about the image to be registered, specify the information to imregister using spatial referencing objects. This helps imregister converge to better results more quickly because scale differences can be taken into account.

Was this topic helpful?