showMatchedFeatures

Display corresponding feature points

Description

example

showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2) displays a falsecolor 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. The input points can be M-by-2 matrices of M number of [x y] coordinates, or SURFPoints, MSERRegions, ORBPoints, BRISKPoints, or cornerPoints object.

example

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

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 specification in I1, marker specification in I2, and line style and color. The LineSpec syntax of the plot function defines each of the specifiers.

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

Examples

collapse all

Read Images.

I1 = rgb2gray(imread('parkinglot_left.png'));
I2 = rgb2gray(imread('parkinglot_right.png'));

Detect SURF 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; ax = axes;
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,'montage','Parent',ax);
title(ax, 'Candidate point matches');
legend(ax, 'Matched points 1','Matched points 2');

Use SURF features to find corresponding points between two images rotated and scaled with respect to each other.

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; ax = axes;
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,'Parent',ax);
title(ax, 'Putative point matches');
legend(ax,'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 a SURFPoints, MSERRegions, ORBPoints, BRISKPoints, or cornerPoints object.

Coordinates of points in image two, specified as an M-by-2 matrix of M number of [x y] coordinates, or as a SURFPoints, MSERRegions, ORBPoints, BRISKPoints, or cornerPoints object.

Display style method, specified as one of the following:

falsecolor:Overlay 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.
montage:Place I1 and I2 next to each other in the same image.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example:

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, a marker specification in I1, a marker specification 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, returned as the handle to the image object returned by showMatchedFeatures.

Introduced in R2012b