extractFeatures
Extract interest point descriptors
Syntax
Description
[
returns
extracted feature vectors, also known as descriptors, and their corresponding
locations, from a binary or intensity image.features
,validPoints
]
= extractFeatures(I
,points
)
The function derives the descriptors from pixels surrounding
an interest point. The pixels represent and match features specified
by a single-point location. Each single-point specifies the center
location of a neighborhood. The method you use for descriptor extraction
depends on the class of the input points
.
[
uses
additional options specified by one or more features
,validPoints
]
= extractFeatures(I
,points
,Name,Value
)Name,Value
pair
arguments.
Examples
Extract Corner Features from an Image.
Read the image.
I = imread('cameraman.tif');
Find and extract corner features.
corners = detectHarrisFeatures(I); [features, valid_corners] = extractFeatures(I, corners);
Display image.
figure; imshow(I); hold on
Plot valid corner points.
plot(valid_corners);
Extract SURF Features from an Image
Read image.
I = imread('cameraman.tif');
Find and extract features.
points = detectSURFFeatures(I); [features, valid_points] = extractFeatures(I, points);
Display and plot ten strongest SURF features.
figure; imshow(I); hold on; plot(valid_points.selectStrongest(10),'showOrientation',true);
Extract MSER Features from an Image
Read image.
I = imread('cameraman.tif');
Find features using MSER with SURF feature descriptor.
regions = detectMSERFeatures(I);
[features, valid_points] = extractFeatures(I,regions,'Upright',true);
Display SURF features corresponding to the MSER ellipse centers.
figure; imshow(I); hold on; plot(valid_points,'showOrientation',true);
Input Arguments
I
— Input image
binary image | M-by-N 2-D grayscale
image
Input image, specified as either a binary or 2-D grayscale image.
Data Types: logical
| single
| double
| int16
| uint8
| uint16
points
— Center location point
SIFTPoints
| BRISKPoints
object | cornerPoints
object | SURFPoints
object | KAZEPoints
object | MSERRegions
object | ORBPoints
object | M-by-2 matrix of [x,y] coordinates
Center location point of a square neighborhood, specified as either a SIFTPoints
, BRISKPoints
, SURFPoints
, KAZEPoints
, MSERRegions
, cornerPoints
, or ORBPoints
object, or an M-by-2 matrix of
M number of [x y] coordinates. The table lists the
possible input classes of points that can be used for
extraction.
Class of Points | |
---|---|
SIFTPoints | Scale-Invariant Feature Transform (SIFT) |
BRISKPoints | Binary Robust Invariant Scalable Keypoints (BRISK) |
SURFPoints object | Speeded-Up Robust Features (SURF) |
MSERRegions object | Maximally Stable Extremal Regions (MSER) |
cornerPoints | Features from Accelerated Segment Test (FAST), Minimum eigen-value, or Harris |
KAZEPoints | Non-linear image pyramid-based rotation and orientation invariant features. Similar to SURF, but contains less noisy points. |
ORBPoints | Oriented FAST and rotated BRIEF (ORB) features. |
M-by-2 matrix of [x y] coordinates | Simple square neighborhood around [x y] point locations |
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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'Method'
,'Block'
specifies
the Block
method for descriptor extraction.
Method
— Descriptor extraction method
'Auto'
(default) | 'SIFT'
| 'BRISK'
| 'FREAK'
| 'SURF'
| 'ORB'
| 'KAZE'
| 'Block'
Descriptor extraction method, specified as 'SIFT'
,
'FREAK'
, 'SURF'
,
'ORB'
, 'Block'
, or
'Auto'
.
The table describes how the function implements the descriptor extraction methods.
Method | Feature Vector (Descriptor) | ||||
---|---|---|---|---|---|
SIFT | Scale-Invariant Feature Transform (SIFT). The
function sets the Orientation property of the
validPoints output object to
the orientation of the extracted features, in
radians. | ||||
BRISK | Binary Robust Invariant Scalable Keypoints (BRISK). The function sets the Orientation property of
the validPoints output object
to the orientation of the extracted features, in
radians. | ||||
FREAK | Fast Retina Keypoint (FREAK). The function sets the Orientation property of the
validPoints output object to
the orientation of the extracted features, in
radians. | ||||
SURF | Speeded-Up Robust Features (SURF).The function sets the Orientation property of the
validPoints output object to
the orientation of the extracted features, in
radians. When you use an | ||||
ORB | Oriented FAST and rotated BRIEF (ORB)
features.The Orientation property of the
validPoints output object is
automatically set to the Orientation property of the input
ORBPoints object
points . | ||||
KAZE | Non-linear pyramid-based features. The
function sets the When you use an The | ||||
Block | Simple square neighbhorhood. The | ||||
Auto | The function selects the Method , based
on the class of the input points and implements:
For an M-by-2 input matrix of
[x y] coordinates, the function
implements the |
BlockSize
— Block size
11
(default) | odd integer scalar
Block size, specified as an odd integer scalar. This value defines the local square
neighborhood
BlockSize-by-BlockSize,
centered at each interest point. This option applies only when the
function implements the Block
method.
Upright
— Rotation invariance flag
false
| logical scalar
Rotation invariance flag, specified a logical scalar. When you set this property to
true
, the orientation of the feature vectors are
not estimated and the feature orientation is set to pi/2. Set this to
true
when you do not need the image descriptors
to capture rotation information. When you set this property to
false
, the orientation of the features is
estimated and the features are then invariant to rotation.
Note
The rotation invariance flag 'Upright'
is not
supported if the input points
is an
ORBPoints
object.
FeatureSize
— Length of feature vector
64
(default) | 128
Length of the SURF or KAZE feature vector (descriptor), specified as
64
or 128
. This option
applies only when the function implements the
SURF
or KAZE
method.
The larger feature size of 128
provides greater
accuracy, but decreases the feature matching speed.
Output Arguments
features
— Feature vectors
M-by-N matrix | binaryFeatures
object
Feature vectors, returned as a binaryFeatures
object or an M-by-N matrix
of M feature vectors, also known as descriptors.
Each descriptor is of length N.
validPoints
— Valid points
SIFTPoints
BRISKPoints
object | cornerPoints
object | SURFPoints
object | KAZEPoints
object | MSERRegions
object | ORBPoints
object | M-by-2 matrix of [x,y] coordinates
Valid points associated with each output feature vector (descriptor) in
features
, returned in the same format as the input.
Valid points can be a SIFTPoints
, BRISKPoints
, cornerPoints
, SURFPoints
, KAZEPoints
, MSERRegions
, ORBPoints
object, or an M-by-2 matrix of
[x,y] coordinates.
The function extracts descriptors from a region around each interest point. If the region lies outside of the image, the function cannot compute a feature descriptor for that point. When the point of interest lies too close to the edge of the image, the function cannot compute the feature descriptor. In this case, the function ignores the point. The point is not included in the valid points output.
References
[1] G. Bradski and A. Kaehler, Learning OpenCV : Computer Vision with the OpenCV Library, O'Reilly, Sebastopol, CA, 2008.
[2] Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool, SURF: Speeded Up Robust Features", Computer Vision and Image Understanding (CVIU), Vol. 110, No. 3, pp. 346--359, 2008
[3] Bay, Herbert, Andreas Ess, Tinne Tuytelaars, and Luc Van Gool, "SURF: Speeded Up Robust Features", Computer Vision and Image Understanding (CVIU), Vol. 110, No. 3, pp. 346--359, 2008.
[4] Alahi, Alexandre, Ortiz, Raphael, and Pierre Vandergheynst, "FREAK: Fast Retina Keypoint", IEEE Conference on Computer Vision and Pattern Recognition, 2012.
[5] Alcantarilla, P.F., A. Bartoli, and A.J. Davison. "KAZE Features", ECCV 2012, Part VI, LNCS 7577 pp. 214, 2012
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
'Method'
must be a compile-time constant.Supports MATLAB® Function block for
BRISK
,FREAK
, andSURF
methods only.Generates portable C code using a C++ compiler that links to OpenCV (Version 4.2.0) libraries for
SIFT
,BRISK
,ORB
,FREAK
, andSURF
Methods. See Portable C Code Generation for Functions That Use OpenCV Library.The
KAZE
method and thedetectKAZEFeatures
function do not support code generation.
Version History
See Also
Objects
Functions
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)