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.

registration.metric.MeanSquares class

Package: registration.metric

Mean square error metric configuration object


A MeanSquares object describes a mean square error metric configuration that you pass to the function imregister to solve image registration problems.


metric = registration.metric.MeanSquares() constructs a MeanSquares object.

Copy Semantics

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


  • This metric is an element-wise difference between two input images. The ideal value is zero. You can examine the computed values of mean square error if you enable 'DisplayOptimization' when you call imregister. For example, movingRegistered = imregister(moving,fixed,'rigid',optimizer,metric,'DisplayOptimization',true);


expand all

Create a MeanSquares object and use it to register two images captured with different sensors.

In general, imregister doesn't support perspective transformations. However it returns good results for this problem, which uses a similarity transformation.

Read the images into the workspace.

fixed  = imread('westconcordorthophoto.png');
moving = rgb2gray(imread('westconcordaerial.png'));

View the misaligned images.

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

Create the optimizer configuration object suitable for registering images from different sensors.

optimizer = registration.optimizer.OnePlusOneEvolutionary;

Create the MeanSquares metric configuration object. Even though the images came from different sensors, they have an intensity relationship similar enough to use mean square error as the similarity metric.

metric = registration.metric.MeanSquares
metric = 


  This class has no properties.

Increase MaximumIterations property of the optimizer to allow for more iterations.

optimizer.MaximumIterations = 1000;

Register the moving and fixed images.

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

View the 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 mean squares image similarity metric is computed by squaring the difference of corresponding pixels in each image and taking the mean of the those squared differences.

Use imregconfig to construct a metric configuration for typical image registration scenarios.

Was this topic helpful?