This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Regular step gradient descent optimizer configuration


A RegularStepGradientDescent object describes a regular step gradient descent optimization configuration that you pass to the function imregister to solve image registration problems.


You can create a RegularStepGradientDescent object using the following methods:

  • imregconfig — Returns a RegularStepGradientDescent object paired with an appropriate metric for registering monomodal images

  • Entering

    metric = registration.optimizer.RegularStepGradientDescent;
    on the command line creates a RegularStepGradientDescent object with default settings


expand all

Gradient magnitude tolerance, specified as a positive scalar. GradientMagnitudeTolerance controls the optimization process. When the value of the gradient is smaller than GradientMagnitudeTolerance, it is an indication that the optimizer might have reached a plateau.

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

Tolerance for convergence, specified as a positive scalar. MinimumStepLength controls the accuracy of convergence. If you set MinimumStepLength to a small value, the optimization takes longer to compute, but it is likely to converge on a more accurate metric value.

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

Initial step length, specified as a positive scalar. The initial step length is the maximum step length because the optimizer reduces the step size during convergence. If you set MaximumStepLength to a large value, the computation time decreases. However, the optimizer might fail to converge if you set MaximumStepLength to an overly large value.

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

Maximum number of iterations, specified as a positive integer scalar. MaximumIterations is a positive scalar integer value that determines the maximum number of iterations the optimizer performs at any given pyramid level. The registration could converge before the optimizer reaches the maximum number of iterations.

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

Step length reduction factor, specified as a positive scalar between 0 and 1. RelaxationFactor defines the rate at which the optimizer reduces step size during convergence. Whenever the optimizer determines that the direction of the gradient changed, it reduces the size of the step length. If your metric is noisy, you can set RelaxationFactor to a larger value. This leads to a more stable convergence at the expense of computation time.

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


expand all

Create a RegularStepGradientDescent object and use it to register two images with similar brightness and contrast.

Read the reference image and create an unregistered copy.

fixed  = imread('pout.tif');
moving = imrotate(fixed, 5, 'bilinear', 'crop');

View the misaligned images.

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

Create the optimizer configuration object suitable for registering monomodal images.

optimizer = registration.optimizer.RegularStepGradientDescent
optimizer = 

    GradientMagnitudeTolerance: 1.000000e-04
             MinimumStepLength: 1.000000e-05
             MaximumStepLength: 6.250000e-02
             MaximumIterations: 100
              RelaxationFactor: 5.000000e-01

Create the metric configuration object.

metric = registration.metric.MeanSquares;

Modify the optimizer configuration to get more precision.

optimizer.MaximumIterations = 300;
optimizer.MinimumStepLength = 5e-4;

Perform the registration.

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

View the registered images.

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


The regular step gradient descent optimization adjusts the transformation parameters so that the optimization follows the gradient of the image similarity metric in the direction of the extrema. It uses constant length steps along the gradient between computations until the gradient changes direction. At this point, the step length is reduced based on the RelaxationFactor, which halves the step length by default.

Introduced in R2012a

Was this topic helpful?