Intensity-based image registration
transforms the 2-D or 3-D grayscale image,
moving_reg = imregister(
moving, so that it
is registered with the reference image,
transformType defines the type of transformation to
metric defines the quantitative measure of similarity
between the images to optimize.
optimizer describes the method
for optimizing the metric. The function returns the registered image,
transforms the spatially referenced image
moving so that it is
registered with the spatially referenced image
Rfixed are spatial
referencing objects that describe the world coordinate limits and the resolution of
___ = imregister(___,
specifies additional options with one or more name-value pair arguments.
Register Multimodal MRI Images with Optimizer
Read two images. This example uses two magnetic resonance (MRI) images of a knee. The fixed image is a spin echo image, while the moving image is a spin echo image with inversion recovery. The two sagittal slices were acquired at the same time but are slightly out of alignment.
fixed = dicomread("knee1.dcm"); moving = dicomread("knee2.dcm");
View the misaligned images.
Create the optimizer and metric, specifying the modality as "
multimodal" because the images come from 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 the registered images.
moving — Image to be registered
numeric matrix | 3-D numeric array
Image to be registered, specified as numeric matrix representing a 2-D grayscale image or a 3-D numeric array representing a 3-D grayscale volume.
fixed — Reference image
numeric matrix | 3-D numeric array
Reference image in the target orientation, specified as numeric matrix
representing a 2-D grayscale image or a 3-D numeric array representing a 3-D
grayscale volume. The reference image must have the same dimensionality as
the image to be registered,
transformType — Geometric transformation to be applied to image to be registered
Geometric transformation to be applied to the moving image, specified as one of the following values:
|(x,y) translation in 2-D, or (x,y,z) translation in 3-D.|
|Rigid transformation consisting of translation and rotation.|
|Nonreflective similarity transformation consisting of translation, rotation, and scale.|
|Affine transformation consisting of translation, rotation, scale, and shear.|
transformation types do not support reflection.
optimizer — Method for optimizing similarity metric
OnePlusOneEvolutionary optimizer object
Method for optimizing the similarity metric, specified as a
metric — Image similarity metric to be optimized during registration
Image similarity metric to be optimized during registration, specified as a
MattesMutualInformation metric object.
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
"DisplayOptimization",1 enables the verbose optimization
DisplayOptimization — Verbose optimization flag
false (default) |
Verbose optimization flag, specified as the logical value
false. Controls whether
imregister displays optimization information in
the command window during the registration process.
InitialTransformation — Initial geometric transformation
affinetform2d object |
Initial geometric transformation, specified as an
You can also specify
affine2d object or an
these objects are not recommended. For more information, see Compatibility Considerations.
PyramidLevels — Number of pyramid levels used during registration process
3 (default) | positive integer
Number of pyramid levels used during the registration process, specified as a positive integer.
"PyramidLevels",4 sets the number of pyramid levels to
moving_reg — Registered image
numeric matrix | 3-D numeric array
Registered image, returned as a 2-D numeric matrix representing a 2-D
grayscale image or a 3-D numeric array representing a 3-D grayscale volume.
Any fill pixels introduced that do not correspond to locations in the
original image are
imregisteruse the same underlying registration algorithm.
imregisterperforms the additional step of resampling
movingto produce the registered output image from the geometric transformation estimate calculated by
imregtformwhen you want access to the geometric transformation that relates
imregisterwhen you want a registered output image.
imregconfigfunction 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
imregconfigfunction 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
imregconfigfor more information on the different parameters that you can modify.
If the spatial scaling of your images differs by more than 10%, resize them with
imresizebefore registering them.
imfuseto visualize the results of registration.
You can use
imregisterin an automated workflow to register several images.
When you have spatial referencing information about the image to be registered, specify the information to
imregisterusing spatial referencing objects. This helps
imregisterconverge to better results more quickly because scale differences can be taken into account.
Version HistoryIntroduced in R2012a
affinetform3d object for geometric transformations
Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the
premultiply convention. Accordingly, you can now specify the
InitialTransformation name-value argument as an
affinetform3d object, which supports the premultiply convention.
Although you can still specify the
name-value argument as an
object, these objects are not recommended because they use the postmultiply
convention. You can streamline your geometric transformation workflows by switching
affinetform3d object. For
more information, see Migrate Geometric Transformations to Premultiply Convention.
imregicp(Medical Imaging Toolbox)