Documentation

showMatchedFeatures

Display corresponding feature points

Syntax

  • showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2)
    example
  • showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,method)
    example
  • showMatchedFeatures(___,PlotOptions, {MarkerStyle1, MarkerStyle2, LineStyle})
  • H = showMatchedFeatures(___)

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, 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 string values. The MarkerStyle1, MarkerStyle2, and LineStyle string 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

Find Corresponding Points Between Two Images Using Harris Features

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');

Display Corresponding Points Between Two Rotated and Scaled Images

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

I1 — Input imagenumeric array

Input image one, specified as a numeric array.

I2 — Input imagenumeric array

Input image two, specified as a numeric array.

matchedPoints1 — Coordinates of pointsM-by-2 matrix | SURFPoints object | MSERRegions object | cornerPoints object | BRISKPoints object

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, cornerPoints, or BRISKPoints object.

matchedPoints2 — Coordinates of pointsM-by-2 matrix | SURFPoints object | MSERRegions object | cornerPoints object | BRISKPoints 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, cornerPoints, or BRISKPoints object.

method — Display methodfalsecolor (default) | blend | montage

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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example:

'PlotOptions' — Line style and color{'ro','g+','y-'} (default) | cell array

Line style and color options, specified as a cell array containing three string values, {MarkerStyle1, MarkerStyle2, LineStyle}, corresponding to a 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.

'Parent' — Output axesaxes graphics object

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

Output Arguments

collapse all

H — Handle to image objecthandle

Handle to image object, returned as the handle to the image object returned by showMatchedFeatures.

Introduced in R2012b

Was this topic helpful?