Tune control point locations using cross-correlation
movingPointsAdjusted = cpcorr(movingPoints,fixedPoints,moving,fixed)
normalized cross-correlation to adjust each pair of control points
movingPointsAdjusted = cpcorr(
cpcorr returns the adjusted control points
must have the same scale for
cpcorr to be effective.
cpcorr cannot correlate a pair of control points,
the same coordinates as
movingPoints for that
Read two images into the workspace.
moving = imread('onion.png'); fixed = imread('peppers.png');
Define sets of control points for both images.
movingPoints = [118 42;99 87]; fixedPoints = [190 114;171 165];
Display the images, and display the control points in white.
figure; imshow(fixed) hold on plot(fixedPoints(:,1),fixedPoints(:,2),'xw') title('fixed')
figure; imshow(moving) hold on plot(movingPoints(:,1),movingPoints(:,2),'xw') title('moving')
Observe the slight errors in the position of the moving points.
Adjust the moving control points using cross correlation.
movingPointsAdjusted = cpcorr(movingPoints,fixedPoints,... moving(:,:,1),fixed(:,:,1))
movingPointsAdjusted = 2×2 115.9000 39.1000 97.0000 89.9000
Display the adjusted moving points in yellow. Compared to the original moving points (in white), the adjusted points more closely match the positions of the fixed points.
movingPoints— Coordinates of control points in the image to be transformed
Coordinates of control points in the image to be transformed,
specified as an M-by-2
movingPoints = [127 93; 74 59];
fixedPoints— Coordinates of control points in the reference image
Coordinates of control points in the reference image, specified
as an M-by-2
fixedPoints = [323 195; 269 161];
moving— Image to be registered
Image to be registered, specified as a numeric array of finite values.
fixed— Reference image in the target orientation
Reference image in the target orientation, specified as a numeric array of finite values.
cpcorr cannot adjust a point if any of the
points are too near the edge of either image
regions of images around points contain
region around a point in moving image has zero standard deviation
regions of images around points are poorly correlated
cpcorr only moves the position of a control
point by up to four pixels. Adjusted coordinates are accurate up to
one-tenth of a pixel.
cpcorr is designed to get
subpixel accuracy from the image content and coarse control point