Selecting Control Points

Specifying Control Points Using the Control Point Selection Tool

To specify control points in a pair of images you want to register, use the Control Point Selection Tool, cpselect. The tool displays the image you want to register, called the input image, next to the image you want to compare it to, called the base image or reference image.

Specifying control points is a four-step process:

  1. Start the tool, specifying the input image and the base image.

  2. Use navigation aids to explore the image, looking for visual elements that you can identify in both images. cpselect provides many ways to navigate around the image, panning and zooming to view areas of the image in more detail.

  3. Specify matching control point pairs in the input image and the base image.

  4. Save the control points in the MATLAB workspace.

The following figure shows the default appearance of the tool when you first start it.

Starting the Control Point Selection Tool

To use the Control Point Selection Tool, enter the cpselect command at the MATLAB prompt. As arguments, specify the image you want to register (the input image), and the image you want to compare it to (the base image).

For simplicity, this section uses the same image as the input and the base image. To walk through an example of an actual registration, see Registering an Image.

moon_base = imread('moon.tif');
moon_input = moon_base; 
cpselect(moon_input, moon_base);

The cpselect command has other optional arguments. For example, you can restart a control point selection session by including a cpstruct structure as the third argument. For more information about restarting sessions, see Exporting Control Points to the Workspace. For complete details, see the cpselect reference page.

When the Control Point Selection Tool starts, it contains three primary components:

The following figure shows these components of the Control Point Selection Tool.

Using Navigation Tools to Explore the Images

To find visual elements that are common to both images, you might want to change the section of the image displayed in the detail view or zoom in on a part of the image to view it in more detail. The following sections describe the different ways to change your view of the images:

Using Scroll Bars to View Other Parts of an Image

To view parts of an image that are not visible in the Detail or Overview windows, use the scroll bars provided for each window.

As you scroll the image in the Detail window, note how the Detail rectangle moves over the image in the Overview window. The position of the Detail rectangle always shows the portion of the image in the Detail window.

Using the Detail Rectangle to Change the View

To get a closer view of any part of the image, move the Detail rectangle in the Overview window over that section of the image. cpselect displays that section of the image in the Detail window at a higher magnification than the Overview window.

To move the detail rectangle,

  1. Move the pointer into the Detail rectangle. The cursor changes to the fleur shape, .

  2. Press and hold the mouse button to drag the detail rectangle anywhere on the image.

Panning the Image Displayed in the Detail Window

To change the section of the image displayed in the Detail window, use the pan tool to move the image in the window.

To use the pan tool,

  1. Click the Pan button in the Control Point Selection Tool toolbar or select Pan from the Tools menu.

  2. Move the pointer over the image in the Detail window. The cursor changes to the hand shape, .

  3. Press and hold the mouse button. The cursor changes to a closed fist shape, . Use the mouse to move the image in the Detail window.

Zooming In and Out on an Image

To enlarge an image to get a closer look or shrink an image to see the whole image in context, you can zoom in or zoom out on the images displayed. (You can also zoom in or out on an image by changing the magnification. See Specifying the Magnification of the Images for more information.)

To zoom in or zoom out on the base or input images,

  1. Click the appropriate magnifying glass button on the Control Point Selection Tool toolbar or select Zoom In or Zoom Out from the Tools menu.

  2. Move the pointer over the image in the Detail window that you want to zoom in or out on. The cursor changes to the appropriate magnifying glass shape, such as . Position the cursor over a location in the image and click the mouse. With each click, cpselect changes the magnification of the image by a preset amount. (SeeSpecifying the Magnification of the Images for a list of some of these magnifications.) cpselect centers the new view of the image on the spot where you clicked.

    Another way to use the Zoom tool to zoom in on an image is to position the cursor over a location in the image and, while pressing and holding the mouse button, draw a rectangle defining the area you want to zoom in on. cpselect magnifies the image so that the chosen section fills the Detail window. cpselect resizes the detail rectangle in the Overview window as well.

    The size of the Detail rectangle in the Overview window changes as you zoom in or out on the image in the Detail window.

    To keep the relative magnifications of the base and input images synchronized as you zoom in or out, click the Lock ratio check box. See Locking the Relative Magnification of the Input and Base Images for more information.

Specifying the Magnification of the Images

To enlarge an image to get a closer look or to shrink an image to see the whole image in context, use the magnification edit box. (You can also use the Zoom buttons to enlarge or shrink an image. See Zooming In and Out on an Image for more information.)

To change the magnification of an image,

  1. Move the cursor into the magnification edit box of the window you want to change. The cursor changes to the text entry cursor.

  2. Type a new value in the magnification edit box and press Enter, or click the menu associated with the edit box and choose from a list of preset magnifications. cpselect changes the magnification of the image and displays the new view in the appropriate window. To keep the relative magnifications of the base and input images synchronized as you change the magnification, click the Lock ratio check box. See Locking the Relative Magnification of the Input and Base Images for more information.

Locking the Relative Magnification of the Input and Base Images

To keep the relative magnification of the input and base images automatically synchronized in the Detail windows, click the Lock Ratio check box.

When the Lock Ratio check box is selected, cpselect changes the magnification of both the input and base images when you zoom in or out on either one of the images or specify a magnification value for either of the images.

Specifying Matching Control Point Pairs

The primary function of the Control Point Selection Tool is to enable you to pick control points in the image to be registered (the input image) and the image to which you are comparing it (the base image). When you start cpselect, point selection is enabled, by default.

You specify control points by pointing and clicking in the input and base images, in either the Detail or the Overview windows. Each point you specify in the input image must have a match in the base image. The following sections describe the ways you can use the Control Point Selection Tool to choose control point pairs:

Picking Control Point Pairs Manually

To specify a pair of control points in your images,

  1. Click the Control Point Selection button in the Control Point Selection Tool toolbar or select Add Points from the Tools menu. (Control point selection mode is active by default.) The cursor changes to a crosshairs shape

  2. Position the cursor over a feature you have visually selected in any of the images displayed and click the mouse button. cpselect places a control point symbol, , at the position you specified, in both the Detail window and the corresponding Overview window. cpselect numbers the points as you select them. The appearance of the control point symbol indicates its current state. The circle around the point indicates that it is the currently selected point. The number identifies control point pairs.

  3. You can select another point in the same image or you can move to the corresponding image and create a match for the point. To create the match for this control point, position the cursor over the same feature in the corresponding Detail or Overview window and click the mouse button. cpselect places a control point symbol at the position you specified, in both the Detail and Overview windows. You can work in either direction: picking control points in either of the Detail windows, input or base, or in either of the Overview windows, input or base.

To match an unmatched control point, select it, and then pick a point in the corresponding window. You can move or delete control points after you create them.

The following figure illustrates control points in several states.

Using Control Point Prediction

Instead of picking matching control points yourself, you can let the Control Point Selection Tool estimate the match for the control points you specify, automatically. The Control Point Selection Tool determines the position of the matching control point based on the geometric relationship of the previously selected control points, not on any feature of the underlying images.

To illustrate point prediction, this figure shows four control points selected in the input image, where the points form the four corners of a square. (The control point selections in the figure do not attempt to identify any landmarks in the image.) The figure shows the picking of a fourth point, in the left window, and the corresponding predicted point in the right window. Note how the Control Point Selection Tool places the predicted point at the same location relative to the other control points, forming the bottom right corner of the square.

To use control point prediction,

  1. Click the Control Point Prediction button .

  2. Position the cursor anywhere in any of the images displayed. The cursor changes to the crosshairs shape, .

    You can pick control points in either of the Detail windows, input or base, or in either of the Overview windows, input or base. You also can work in either direction: input-to-base image or base-to-input image.

  3. Click either mouse button. The Control Point Selection Tool places a control point symbol at the position you specified and places another control point symbol for a matching point in all the other windows. The symbol for the predicted point contains the letter P, indicating that it's a predicted control point,

  4. To accept a predicted point, select it with the cursor and move it. The Control Point Selection Tool removes the P from the point.

Moving Control Points

To move a control point,

  1. Click the Control Point Selection button .

  2. Position the cursor over the control point you want to move. The cursor changes to the fleur shape,

  3. Press and hold the mouse button and drag the control point. The state of the control point changes to selected when you move it.

If you move a predicted control point, the state of the control point changes to a regular (nonpredicted) control point.

Deleting Control Points

To delete a control point, and its matching point, if one exists

  1. Click the Control Point Selection button .

  2. Click the control point you want to delete. Its state changes to selected. If the control point has a match, both points become active.

  3. Delete the point (or points) using one of these methods:

Exporting Control Points to the Workspace

After you specify control point pairs, you must save them in the MATLAB workspace to make them available for the next step in image registration, processing by cp2tform.

To save control points to the MATLAB workspace,

  1. Select File on the Control Point Selection Tool menu bar.

  2. Choose the Export Points to Workspace option. The Control Point Selection Tool displays this dialog box:

By default, the Control Point Selection Tool saves the x-coordinates and y-coordinates that specify the locations of the control points you selected in two arrays named input_points and base_points, although you can specify other names. These are n-by-2 arrays, where n is the number of valid control point pairs you selected. This example shows the input_points array containing four pairs of control points. The values in the left column represent the x-coordinates; the values in the right column represent the y-coordinates.

input_points =

  215.6667  262.3333
  225.7778  311.3333
  156.5556  340.1111
  270.8889  368.8889

Whenever you exit the Control Point Selection Tool, it asks if you want to save your control points.

Saving Your Control Point Selection Session

To save the current state of the Control Point Selection Tool, choose the Export Points to Workspace option from the File menu. In the Export Points to Workspace dialog box, select the Structure with all points check box.

This option saves the positions of all the control points you specified and their current states in a cpstruct structure.

cpstruct = 

         inputPoints: [4x2 double]
          basePoints: [4x2 double]
      inputBasePairs: [4x2 double]
                 ids: [4x1 double]
        inputIdPairs: [4x2 double]
         baseIdPairs: [4x2 double]
    isInputPredicted: [4x1 double]
     isBasePredicted: [4x1 double]

You can use the cpstruct to restart a control point selection session at the point where you left off.

This option is useful if you are picking many points over a long time and want to preserve unmatched and predicted points when you resume work. The Control Point Selection Tool does not include unmatched and predicted points in the input_points and base_points arrays.

To extract the arrays of valid control point coordinates from a cpstruct, use the cpstruct2pairs function.


Maintained by John Loomis, last updated 9 April 2010