Configurations for intensity-based registration
configurations that you pass to
imregister to perform
intensity-based image registration, where
the image capture modality.
Create Optimizer and Metric to Register Monomodal Images
Load the images into the workspace and display them. These images are monomodal because they have similar brightness and contrast.
fixed = imread('pout.tif'); moving = imrotate(fixed, 5, 'bilinear', 'crop'); imshowpair(fixed, moving,'Scaling','joint')
Create the optimizer and metric, setting the modality to
[optimizer, metric] = imregconfig('monomodal')
optimizer = registration.optimizer.RegularStepGradientDescent Properties: GradientMagnitudeTolerance: 1.000000e-04 MinimumStepLength: 1.000000e-05 MaximumStepLength: 6.250000e-02 MaximumIterations: 100 RelaxationFactor: 5.000000e-01
metric = registration.metric.MeanSquares This class has no properties.
Pass the optimizer and metric to
imregister to perform the registration.
movingRegistered = imregister(moving,fixed,'rigid',optimizer, metric);
View the registered images
figure imshowpair(fixed, movingRegistered,'Scaling','joint')
Register Multimodal MRI Images with Optimizer
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, specifying the modality as "
multimodal" because 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.
modality — Image capture modality
Image capture modality, specified as one of these values.
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.
optimizer — Optimization configuration
Optimization configuration, returned as a
metric — Metric configuration
Metric configuration describes the image similarity metric to be optimized during
registration, returned as a
metricwith default settings to provide a basic registration configuration. If you adjust the optimizer or metric properties, then 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.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version HistoryIntroduced in R2012a
R2021b: Support for thread-based environments
imregconfig now supports thread-based