Intensity-based image registration
moving_reg = imregister(moving,fixed,transformType,optimizer,metric)
[moving_reg,R_reg] = imregister(moving,Rmoving,fixed,Rfixed,transformType,optimizer,metric)
___ = imregister(___,Name,Value)
the 2-D or 3-D image,
moving_reg = imregister(
moving, so that it is registered
with the reference image,
must be of the same dimensionality, either 2-D or 3-D.
a character vector that defines the type of transformation to perform.
an object that describes the method for optimizing the metric.
an object that defines the quantitative measure of similarity between
the images to optimize. Returns the aligned image,
the spatially referenced image
moving so that
it is registered with the spatially referenced image
spatial referencing objects that describe the world coordinate limits
and the resolution of
___ = imregister(___, specifies
additional options with one or more
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, setting the modality to
'multimodal' since 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.
figure imshowpair(fixed, movingRegistered,'Scaling','joint')
moving— Image to be registered
Image to be registered, specified as a 2-D or 3-D grayscale image.
Rmoving— Spatial referencing information associated with the image to be registered
fixed— Reference image in the target orientation
Reference image in the target orientation, specified as a grayscale image.
Rfixed— Spatial referencing information associated with the reference image
transformType— Geometric transformation to be applied to the 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.|
types always involve nonreflective transformations.
optimizer— Method for optimizing the similarity metric
Method for optimizing the similarity metric, specified as a
object. To learn more about the creation and properties of optimizer
metric— Image similarity metric to be optimized during registration
Specify optional comma-separated pairs of
Name is the argument
Value is the corresponding
Name must appear
inside single quotes (
You can specify several name and value pair
arguments in any order as
'DisplayOptimization',1enables the verbose optimization mode.
'DisplayOptimization'— Verbose optimization flag
Verbose optimization flag, specified as the comma-separated
pair consisting of
'DisplayOptimization', and the
imregister displays optimization
information in the command window during the registration process.
'InitialTransformation'— Starting geometric transformation
affine3dgeometric transformation object
'PyramidLevels'— Number of pyramid levels used during registration process
3(default) | positive integer
Number of pyramid levels used during the registration process,
specified as the comma-separated pair consisting of
a positive integer.
'PyramidLevels',4 sets the number
of pyramid levels to
moving_reg— Transformed image
Transformed image, returned as a matrix. Any fill pixels introduced
that do not correspond to locations in the original image are
the same underlying registration algorithm.
the additional step of resampling
moving to produce
the registered output image from the geometric transformation estimate
you want access to the geometric transformation that relates
imregister when you want a registered output
imregconfig function before
imregister. Getting good results from
optimization-based image registration usually requires modifying optimizer
or metric settings for the pair of images being registered. The
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
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
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
spatial referencing objects. This helps
to better results more quickly because scale differences can be taken