Accelerating the pace of engineering and science

# registration.metric.MeanSquares class

Package: registration.metric

Mean square error metric configuration object

## Description

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

## Construction

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.

## Tips

• 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);

## Examples

expand all

### Register Remote Sensing Images with MeanSquares Metric

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');

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 =

registration.metric.MeanSquares

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.

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

## Algorithms

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.