Configurations for intensity-based registration
[optimizer,metric] = imregconfig(modality)
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.
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,'Scaling','joint')
optimizer— Optimization configuration
metric— Metric configuration
Metric configuration describes the image similarity metric to
be optimized during registration, returned as a
object. To learn more about the creation and properties of metric
Monomodal images have similar brightness and contrast. The images are captured on the same type of scanner or sensor.
Multimodal images have different brightness and contrast. The images can come from two different types of devices, such as two camera models or two types of medical imaging modalities (like CT and MRI). The images can also come from a single device, such as a camera using different exposure settings, or an MRI scanner using different imaging sequences.
If you adjust the optimizer or metric parameters, the registration results can improve. 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.