Main Content

imregister

Intensity-based image registration

Description

example

moving_reg= imregister(moving,fixed,transformType,optimizer,metric)transforms the 2-D or 3-D grayscale image,moving,以便将其注册为参考图像,fixedtransformTypedefines the type of transformation to perform.metricdefines the quantitative measure of similarity between the images to optimize.optimizerdescribes the method for optimizing the metric. The function returns the registered image,moving_reg

[moving_reg,R_reg] = imregister(moving,Rmoving,fixed,rfixed,transformType,optimizer,metric)transforms the spatially referenced imagemovingso that it is registered with the spatially referenced imagefixedRmovingandrfixedare spatial referencing objects that describe the world coordinate limits and the resolution ofmovingandfixed

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

Examples

collapse all

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.

imshowpair(fixed, moving,“缩放”,'joint')

Figure contains an axes object. The axes object contains an object of type image.

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,“缩放”,'joint')

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

collapse all

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.

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

Spatial referencing information associated with the image to be registered, specified as animref2dobject orimref3dobject.

参考图像在目标或者ientation, 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,moving

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

与参考(固定)图像相关的空间引用信息,指定为imref2dobject orimref3dobject.

Geometric transformation to be applied to the moving image, specified as one of the following values:

Value Description
'translation' (x,y) translation in 2-D, or (x,y,z) translation in 3-D.
'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.

Data Types:char|string

Method for optimizing the similarity metric, specified as aRegularStepGradientDescent或者OnePlusOneEvolutionaryoptimizer object.

Image similarity metric to be optimized during registration, specified as aMeanSquares或者MattesMutualInformationmetric object.

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein quotes.

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

Verbose optimization flag, specified as the comma-separated pair consisting of'DisplayOptimization', and the logical valuetrue或者.控制是否imregisterdisplays optimization information in the command window during the registration process.

Data Types:logical

从几何变换, specified as the comma-separated pair consisting of“初始转化”and anaffine2dobject oraffine3dobject.

Number of pyramid levels used during the registration process, specified as the comma-separated pair consisting of'PyramidLevels'and a positive integer.

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

Data Types:double

Output Arguments

collapse all

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 are0

Spatial referencing information associated with the registered image, returned as animref2dobject orimref3dobject.

Tips

  • Bothimregtformandimregisteruse the same underlying registration algorithm.imregisterperforms the additional step of resamplingmovingto produce the registered output image from the geometric transformation estimate calculated byimregtform.Useimregtformwhen you want access to the geometric transformation that relatesmovingtofixed.Useimregisterwhen you want a registered output image.

  • Create anoptimizerandmetricwith theimregconfigfunction before callingimregister.Getting good results from optimization-based image registration usually requires modifying optimizer or metric settings for the pair of images being registered. Theimregconfigfunction 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 ofimregconfigfor more information on the different parameters that you can modify.

  • If the spatial scaling of your images differs by more than 10%, resize them withimresizebefore registering them.

  • Useimshowpair或者imfuseto visualize the results of registration.

  • You can useimregisterin an automated workflow to register several images.

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

Version History

Introduced in R2012a