Main Content

showMatchedFeatures

Display corresponding feature points

Description

showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2) displays an overlay of images I1 and I2 with a color-coded plot of corresponding points connected by a line. matchedPoints1 and matchedPoints2 contain the coordinates of corresponding points in I1 and I2.

example

showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,method) displays images I1 and I2 using the visualization style specified by the method parameter.

example

showMatchedFeatures(___,PlotOptions, {MarkerStyle1, MarkerStyle2, LineStyle}) lets you specify custom plot options in a cell array containing three values. The MarkerStyle1, MarkerStyle2, and LineStyle values correspond to the marker symbol in I1, marker symbol in I2, and the line style and color. The LineSpec syntax of the plot function defines each of the specifiers.

showMatchedFeatures(___,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, showMatchedFeatures(__,PlotOptions={"d","+","g"}) sets the marker style to a diamond for I1, a plus sign for I2, and the color to green.

H = showMatchedFeatures(___) returns the handle to the image object returned by showMatchedFeatures.

Examples

collapse all

Read Images.

I1 = im2gray(imread("parkinglot_left.png"));
I2 = im2gray(imread("parkinglot_right.png"));

Detect Harris features.

points1 = detectHarrisFeatures(I1);
points2 = detectHarrisFeatures(I2);

Extract features

[f1,vpts1] = extractFeatures(I1,points1);
[f2,vpts2] = extractFeatures(I2,points2);

Match features.

indexPairs = matchFeatures(f1,f2);
matchedPoints1 = vpts1(indexPairs(1:20,1));
matchedPoints2 = vpts2(indexPairs(1:20,2));

Visualize candidate matches.

figure; 
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,"montage");
title("Candidate point matches");
legend("Matched points 1","Matched points 2");

Figure contains an axes object. The hidden axes object with title Candidate point matches contains 4 objects of type image, line. One or more of the lines displays its values using only markers These objects represent Matched points 1, Matched points 2.

Read images.

I1 = imread("cameraman.tif");
I2 = imresize(imrotate(I1,-20), 1.2);

Detect SURF features.

points1 = detectSURFFeatures(I1);
points2 = detectSURFFeatures(I2);

Extract features.

[f1,vpts1] = extractFeatures(I1,points1);
[f2,vpts2] = extractFeatures(I2,points2);

Match features.

indexPairs = matchFeatures(f1,f2);
matchedPoints1 = vpts1(indexPairs(:,1));
matchedPoints2 = vpts2(indexPairs(:,2));

Visualize candidate matches.

figure;
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);
title("Putative point matches");
legend("Matched points 1","Matched points 2");

Figure contains an axes object. The hidden axes object with title Putative point matches contains 4 objects of type image, line. One or more of the lines displays its values using only markers These objects represent Matched points 1, Matched points 2.

Input Arguments

collapse all

Input image one, specified as a numeric array.

Input image two, specified as a numeric array.

Coordinates of points in image one, specified as an M-by-2 matrix of M number of [x y] coordinates, or as one of the point feature objects described in Point Feature Types.

Coordinates of points in image two, specified as an M-by-2 matrix of M number of [x y] coordinates, or as one of the point feature objects described in Point Feature Types.

Display style method, specified as one of the following:

falsecolorOverlay the images by creating a composite red-cyan image showing I1 as red and I2 as cyan.
blend Overlay I1 and I2 using alpha blending.
montagePlace I1 and I2 next to each other in the same image.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: showMatchedFeatures(__,PlotOptions={"d","+","g"}) sets the marker style to a diamond for I1, a plus sign for I2, and the color to green.

Marker, line style, and color options, specified as a cell array of character vectors or a string array. The three values {MarkerStyle1, MarkerStyle2, LineStyle}, correspond to the marker symbol in I1, the marker symbol in I2, and the line style and color. The LineSpec syntax of the plot function defines each of the specifiers.

Output axes for displaying visualization, specified as an axes graphics object.

Output Arguments

collapse all

Handle to image object, displayed by showMatchedFeatures.

Version History

Introduced in R2012b