This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Tune control-point locations using cross correlation


  • movingPointsAdjusted = cpcorr(movingPoints,fixedPoints,moving,fixed)



movingPointsAdjusted = cpcorr(movingPoints,fixedPoints,moving,fixed) uses normalized cross correlation to adjust each pair of control points specified in movingPoints and fixedPoints. moving and fixed are images. cpcorr returns the adjusted control points in movingPointsAdjusted.

    Note:   The moving and fixed images must have the same scale for cpcorr to be effective. If cpcorr cannot correlate a pairs of control points, movingPointsAdjusted will contain the same coordinates as movingPoints for that pair.


collapse all

Use cpcorr to fine-tune control points selected in an image. Note the difference in the values of the movingPoints matrix and the movingPointsAdjusted matrix.

Read two images.

moving = imread('onion.png');
fixed = imread('peppers.png');

Define sets of control points for both images.

movingPoints = [127 93; 74 59];
fixedPoints = [323 195; 269 161];

Adjust the control points using cross correlation.

movingPointsAdjusted = cpcorr(movingPoints,fixedPoints,...
movingPointsAdjusted =

   127    93
    72    60

Input Arguments

collapse all

Coordinates of control points in the image to be transformed, specified as an M-by-2 double matrix.

Example: movingPoints = [127 93; 74 59];

Data Types: double

Coordinates of control points in the reference image, specified as an M-by-2 double matrix.

Example: fixedPoints = [323 195; 269 161];

Data Types: double

Image to be registered, specified as a numeric array of finite values.

Reference image in the target orientation, specified as a numeric array of finite values.

Output Arguments

collapse all

Adjusted coordinates of control points in the image to be transformed, returned as a double matrix the same size as movingPoints.

More About

collapse all


cpcorr cannot adjust a point if any of the following occur:

  • points are too near the edge of either image

  • regions of images around points contain Inf or NaN

  • region around a point in moving image has zero standard deviation

  • regions of images around points are poorly correlated


cpcorr will only move 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 selection.

Introduced before R2006a

Was this topic helpful?