addImageFeatures
Description
addImageFeatures(
adds image imageIndex
,features
,imageId
)features
to imageIndex
from the
image specified by imageId
.
Examples
Add Image Features of Image Image Index
Define a set of images.
imageFiles = ... {'elephant.jpg','cameraman.tif', ... 'peppers.png','saturn.png', ... 'pears.png','stapleRemover.jpg', ... 'football.jpg','mandi.tif', ... 'kids.tif','liftingbody.png', ... 'office_5.jpg','gantrycrane.png', ... 'moon.tif','circuit.tif', ... 'tape.png'};
Create an image datastore containing the images.
imds = imageDatastore(imageFiles);
Learn the visual vocabulary of the images.
bag = bagOfFeatures(imds);
Creating Bag-Of-Features. ------------------------- * Selecting feature point locations using the Grid method. * Extracting SURF features from the selected feature point locations. ** The GridStep is [8 8] and the BlockWidth is [32 64 96 128]. * Extracting features from 15 images...done. Extracted 655092 features. * Keeping 80 percent of the strongest features from each category. * Creating a 500 word visual vocabulary. * Number of levels: 1 * Branching factor: 500 * Number of clustering steps: 1 * [Step 1/1] Clustering vocabulary level 1. * Number of features : 524074 * Number of clusters : 500 * Initializing cluster centers...100.00%. * Clustering...completed 53/100 iterations (~3.74 seconds/iteration)...converged in 53 iterations. * Finished creating Bag-Of-Features
Create an image search index.
imageIndex = invertedImageIndex(bag,'SaveFeatureLocations',false);
Load an image and extract features from it.
I = imread('coins.png');
Detect SURF points from the image.
points = detectSURFFeatures(I);
Extract image features from the SURF points.
features = extractFeatures(I,points);
Add the image features into the image index.
imageId = 1; addImageFeatures(imageIndex,features,imageId)
Input Arguments
imageIndex
— Image search index
invertedImageIndex
object
Image search index, specified as an invertedImageIndex
object.
features
— Feature descriptors
M-by-N matrix | binaryFeatures
object
Feature descriptors, specified as an
M-by-N matrix or a binaryFeatures
object. Each
descriptor is of length N. To add image features to the
image index using addImageFeatures
, you must set the
SaveFeatureLocations
property of the invertedImageIndex
object to
false
.
imageId
— Indexed image identifier
positive integer
Indexed image identifier, specified as a positive integer.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2021b
See Also
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)