Main Content


Add new images to image index



addImages(imageIndex,imds) adds the images in imds to imageIndex.

addImages(imageIndex,I,imageId) adds an image, I, to imageIndex, specified by the image identifier imageId.

addImages(___,Verbose=tf) specifies whether or not to display progress information, in addition to any combination of input arguments from previous syntaxes. By default, the addImages function displays progress information. To hide the display, specify tf as false.


collapse all

Define a set of images to search

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',     'coins.png'};

imds = imageDatastore(imageFiles);

Learn the visual vocabulary of the image view set.

numlevels = 1;
branchingFactor = 1000;
bag = bagOfFeatures(imds,'PointSelection','Detector', ...

Create an image search index.

imageIndex = invertedImageIndex(bag);

Add to the image view set images to the image search index.

Encoding images using Bag-Of-Features.

* Encoding 16 images...done.

Input Arguments

collapse all

Image search index, specified as an invertedImageIndex object.

Images, specified as an ImageDatastore object. imds contains new images to add to an existing index. The function does not ignore duplicate images.

Input image, specified as either an M-by-N-by-3 array, representing a truecolor image, or an M-by-N array, representing a 2-D grayscale image.

Indexed image identifier, specified as an positive integer.


  • The addImages function supports parallel computing using multiple MATLAB® workers. Enable parallel computing from the Computer Vision Toolbox Preferences dialog box. To open Computer Vision Toolbox™ preferences, on the Home tab, in the Environment section, select Preferences. Then select Computer Vision Toolbox.

Extended Capabilities

Version History

Introduced in R2015a