Control Point Selection Tool
h = cpselect(moving,fixed,___)
cpselect(moving,fixed) starts the Control Point Selection Tool, a graphical user interface that enables you to select control points in two related images. moving is the image that needs to be warped to bring it into the coordinate system of the fixed image. moving and fixed can be either variables that contain grayscale, truecolor, or binary images, or strings that identify files containing these images. The Control Point Selection Tool returns the control points in a CPSTRUCT structure. (For more information, see Control Point Selection Procedure.)
cpselect(moving,fixed,CPSTRUCT_IN) starts cpselect with an initial set of control points that are stored in CPSTRUCT_IN. This syntax allows you to restart cpselect with the state of control points previously saved in CPSTRUCT_IN.
cpselect(moving,fixed,movingPoints,fixedPoints) starts cpselect with a set of initial pairs of control points. movingPoints and fixedPoints are m-by-2 matrices that store the moving and fixed coordinates, respectively.
cpselect(___,param1, val1,___) starts cpselect, specifying parameters and corresponding values that control various aspects of the tool. Parameter names can be abbreviated, and case does not matter. Parameters include:
Logical scalar that controls whether cpselect waits for the user to finish the task of selecting points. If set to false (the default), you can run cpselect at the same time as you run other programs in MATLAB®. If set to true, you must finish the task of selecting points before doing anything else in MATLAB.
The value affects the output arguments:
= cpselect(...,'Wait',false) returns a handle h to
the tool. close(h) closes the tool.
[moving_out,fixed_out] = cpselect(...,'Wait', true) returns the selected pairs of points. moving_out and fixed_out are P-by-2 matrices that store the moving and fixed image coordinates, respectively.
The images can be grayscale, truecolor, or binary. A grayscale image can be uint8, uint16, int16, single, or double. A truecolor image can be uint8, uint16, single, or double. A binary image is of class logical.
Start Control Point Selection tool with saved images.
Start Control Point Selection tool with images and control points stored in variables in the workspace.
I = checkerboard; J = imrotate(I,30); fixedPoints = [11 11; 41 71]; movingPoints = [14 44; 70 81]; cpselect(J,I,movingPoints,fixedPoints);
Register an aerial photo to an orthophoto. Specify the 'wait' parameter to block until control point selection is complete.
aerial = imread('westconcordaerial.png'); figure, imshow(aerial) ortho = imread('westconcordorthophoto.png'); figure, imshow(ortho) load westconcordpoints % load some points that were already picked % Ask cpselect to wait for you to pick some more points [aerial_points,ortho_points] = ... cpselect(aerial,'westconcordorthophoto.png',... movingPoints,fixedPoints,... 'Wait',true); t_concord = fitgeotrans(aerial_points,ortho_points,'projective'); Rortho = imref2d(size(ortho)); aerial_registered = imwarp(aerial,t_concord,'OutputView',Rortho); figure, imshowpair(aerial_registered,ortho,'blend')
cpselect uses the following general procedure for control-point prediction.
4 or more pairs
Apply spatial transformation to the new point to generate the predicted point.
Display predicted point.