Main Content

addImageFeatures

Add features of image to image index

Since R2021b

Description

addImageFeatures(imageIndex,features,imageId) adds image features to imageIndex from the image specified by imageId.

example

Examples

collapse all

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.59 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

collapse all

Image search index, specified as an invertedImageIndex 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.

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