Extract interest point descriptors
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
Extract Corner Features From an Image.
Read the image.
I = imread("cameraman.tif");
Find and extract corner features from the image.
corners = detectHarrisFeatures(I); [features,valid_corners] = extractFeatures(I,corners);
figure; imshow(I); hold on
Plot valid corner points.
Extract SURF Features From an Image
I = imread("cameraman.tif");
Find and extract features from the input image.
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
I = imread("cameraman.tif");
Find features in the image using MSER feature detection.
regions = detectMSERFeatures(I); [features,valid_points] = extractFeatures(I,regions,Upright=true);
Display features corresponding to the MSER ellipse centers.
figure; imshow(I); hold on; plot(valid_points,showOrientation=true);
I — Input image
binary image | M-by-N 2-D grayscale
Input image, specified as either a binary or 2-D grayscale image.
points — Center location point
M-by-2 matrix | point feature object
Center location point of a square neighborhood,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. The table lists the possible input classes of points that can be used for extraction.
Specify optional pairs of arguments as
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.
extractFeatures(I,points,Method="Block") sets the method to
extract descriptors to
Method — Descriptor extraction method
"Auto" | point feature object | M-by-2 matrix
Descriptor extraction method, specified as one of the point feature objects described in Point Feature Types or
When you set
the function selects the method based on the class of the input points
BlockSize — Block size
11 (default) | odd integer scalar
Block size, specified as an odd integer scalar. This value defines the local square
centered at each interest point. This option applies only when the
function implements the
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.
The rotation invariance flag
"Upright" is not
supported if the input
points is an
FeatureSize — Length of feature vector
64 (default) |
Length of the feature vector (descriptor), specified as
128. This option
applies only when the function implements the
The larger feature size of
128 provides greater
accuracy, but decreases the feature matching speed.
features — Feature vectors
M-by-N matrix |
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
M-by-2 matrix of [x,y] coordinates | point feature object
Valid points associated with each output feature vector (descriptor) in
features, returned in the same format as the input.
Valid points can be a or an M-by-2 matrix of [x,y]
coordinates or as one of the point feature objects described in Point Feature Types.
The function extracts descriptors from a region around each interest point. If the region lies outside of the image, or if interest point 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.
SIFT features, more than one descriptor can be
extracted at a single location, but at different orientations. Therefore,
the number of points returned in
validPoints can be
greater than or equal to the number of input points to
extractFeatures. For input feature points other than
validPoints can be less
than or equal to the number of input points.
 G. Bradski and A. Kaehler, Learning OpenCV : Computer Vision with the OpenCV Library, O'Reilly, Sebastopol, CA, 2008.
 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
 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.
 Alahi, Alexandre, Ortiz, Raphael, and Pierre Vandergheynst, "FREAK: Fast Retina Keypoint", IEEE Conference on Computer Vision and Pattern Recognition, 2012.
 Alcantarilla, P.F., A. Bartoli, and A.J. Davison. "KAZE Features", ECCV 2012, Part VI, LNCS 7577 pp. 214, 2012
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
Generates portable C code using a C++ compiler that links to OpenCV (Version 4.2.0) libraries for
SURFMethods. See Portable C Code Generation for Functions That Use OpenCV Library.
KAZEmethod and the
detectKAZEFeaturesfunction do not support code generation.
Introduced in R2011a