Control Point Selection Tool
cpselect(input, base)
cpselect(input, base, CPSTRUCT_IN)
cpselect(input, base, xyinput_in, xybase_in)
h = cpselect(input, base,...)
cpselect(...,param1, val1,...)
cpselect(input, base) starts the Control Point Selection Tool, a graphical user interface that enables you to select control points in two related images. input is the image that needs to be warped to bring it into the coordinate system of the base image. input and base 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.
cpselect(input, base, 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(input, base, xyinput_in, xybase_in) starts cpselect with a set of initial pairs of control points. xyinput_in and xybase_in are m-by-2 matrices that store the input and base coordinates, respectively.
h = cpselect(input, base,...) returns a handle h to the tool. You can use the close(h) syntax to close the tool from the command line.
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:
Parameter | Description |
---|---|
'Wait' | 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 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.
cpselect uses the following general procedure for control-point prediction.
Infer a spatial transformation between input and base control points using method that depends on the number of valid pairs, as follows:
2 pairs | Nonreflective similarity |
3 pairs | Affine |
4 or more pairs | Projective |
Apply spatial transformation to the new point to generate the predicted point.
Display predicted point.
Start Control Point Selection tool with saved images.
cpselect('westconcordaerial.png','westconcordorthophoto.png')
Start Control Point Selection tool with images and control points stored in variables in the workspace.
I = checkerboard; J = imrotate(I,30); base_points = [11 11; 41 71]; input_points = [14 44; 70 81]; cpselect(J, I, input_points, base_points);
Use cpselect in a script, specifying the 'wait' parameter to block until control point selection is complete.
aerial = imread('westconcordaerial.png'); figure, imshow(aerial) figure, imshow('westconcordorthophoto.png') load westconcordpoints % load preselected control points % Block the tool until you pick some more control points [aerial_points,ortho_points] = ... cpselect(aerial,'westconcordorthophoto.png',... input_points,base_points,... 'Wait',true); t_concord = cp2tform(aerial_points,ortho_points,'projective'); info = imfinfo('westconcordorthophoto.png'); aerial_registered = imtransform(aerial, t_concord,... 'XData',[1 info.Width],... 'YData',[1 info.Height]); figure, imshow(aerial_registered)