Documentation Center

  • Trial Software
  • Product Updates

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

expand all

Find Corresponding Points Between Two Images Using Harris Features

Read images.

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

SURF features.

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

Extract features.

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

Match features.

index_pairs = matchFeatures(f1, f2) ;
matched_pts1 = vpts1(index_pairs(1:20, 1));
matched_pts2 = vpts2(index_pairs(1:20, 2));

Visualize putative matches.

figure; showMatchedFeatures(I1,I2,matched_pts1,matched_pts2,'montage');
 
title('Putative point matches');
legend('matchedPts1','matchedPts2');

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

SURF features.

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

Extract features.

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

Match features.

index_pairs = matchFeatures(f1, f2) ;
matched_pts1 = vpts1(index_pairs(:, 1));
matched_pts2 = vpts2(index_pairs(:, 2));

Visualize putative matches.

figure; showMatchedFeatures(I1,I2,matched_pts1,matched_pts2);
title('Putative point matches');
legend('matchedPts1','matchedPts2');

Input Arguments

expand 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 corresponding pointsM-by-2 matrix | SURFPoints object | MSERRegions object | cornerPoints object

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

matchedPoints2 — Coordinates of corresponding pointsM-by-2 matrix | SURFPoints object | MSERRegions object | cornerPoints object

Coordinates of corresponding points in image one, specified as an M-by-2 matrix of M number of [x y] coordinates, or as a SURFPoints, MSERRegions, or cornerPoints 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.

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.

Output Arguments

expand all

H — Handle to image objecthandle

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

See Also

| | | | | |

Was this topic helpful?