Documentation Center

  • Trial Software
  • Product Updates

registration.optimizer.RegularStepGradientDescent class

Package: registration.optimizer

Regular step gradient descent optimizer configuration object


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


optimizer = registration.optimizer.RegularStepGradientDescent() constructs a RegularStepGradientDescent object.



Gradient magnitude tolerance.

GradientMagnitudeTolerance is a positive scalar value that 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. The default value of GradientMagnitudeTolerance is 1e-4.


Tolerance for convergence.

MinimumStepLength is a positive scalar value that 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. The default value of MinimumStepLength is 1e-5.


Initial step length.

MaximumStepLength is a positive scalar value that controls the initial step length used in optimization. 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. The default value of MaximumStepLength is 0.0625.


Maximum number of iterations.

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. The default value of MaximumIterations is 100.


Step length reduction factor.

RelaxationFactor is a scalar value between 0 and 1 that 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. The default value of RelaxationFactor is 0.5.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.


expand all

Register Images with RegularStepGradientDescent Optimizer

Create a RegularStepGradientDescent object and use it to register two images captured with the same device.

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 images from the same device.

optimizer = registration.optimizer.RegularStepGradientDescent

Create the metric configuration object.

metric = registration.metric.MeanSquares;

Now 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 registered images.

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


The imregister function uses an iterative process to register images. The metric you pass to imregister defines the image similarity metric for evaluating the accuracy of the registration. An image similarity metric takes two images and returns a scalar value that describes how similar the images are. The optimizer you pass to imregister defines the methodology for minimizing or maximizing the similarity metric.

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 which point the step length is halved.

Use imregconfig to construct an optimizer configuration for typical image registration scenarios.

See Also


More About

Was this topic helpful?