cpcorr - Tune control-point locations using cross correlation

Syntax

input_points = cpcorr(input_points_in, base_points_in, input,base)

Description

input_points = cpcorr(input_points_in, base_points_in, input,base) uses normalized cross-correlation to adjust each pair of control points specified in input_points_in and base_points_in.

input_points_in must be an M-by-2 double matrix containing the coordinates of control points in the input image. base_points_in is an M-by-2 double matrix containing the coordinates of control points in the base image.

cpcorr returns the adjusted control points in input_points, a double matrix the same size as input_points_in. If cpcorr cannot correlate a pair of control points, input_points contains the same coordinates as input_points_in for that pair.

cpcorr only moves the position of a control point by up to four pixels. Adjusted coordinates are accurate to one-tenth of a pixel. cpcorr is designed to get subpixel accuracy from the image content and coarse control-point selection.

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

Class Support

The images input and base can be numeric and must contain finite values. The control-point pairs are of class double.

Algorithm

cpcorr uses the following general procedure.

For each control-point pair,

  1. Extract an 11-by-11 template around the input control point and a 21-by-21 region around the base control point.

  2. Calculate the normalized cross-correlation of the template with the region.

  3. Find the absolute peak of the cross-correlation matrix.

  4. Use the position of the peak to adjust the coordinates of the input control point.

Examples

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

input = imread('onion.png');
base = imread('peppers.png');
input_points = [127 93; 74 59];
base_points = [323 195; 269 161];
input_points_adj = cpcorr(input_points,base_points,...
                          input(:,:,1),base(:,:,1))
input_points_adj =

   127.0000   93.0000
    71.0000   59.6000

See Also

cp2tform, cpselect, imtransform, normxcorr2

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS