imageDatastore
to store the image data. Use a large number of images that represent various viewpoints of the object. A large and diverse number of images helps train the bag of visual words and increases the accuracy of the image search.indexImages
function createsthe bag of visual words using the speeded up robust features (SURF).For other types of features, you can use a custom extractor, and thenuse bagOfFeatures
to createthe bag of visual words. See the Create Search Index Using Custom Bag of Features example.imgSet
or a differentcollection of images for the training set. To use a different collection,create the bag of visual words before creating the image index, usingthe bagOfFeatures
function.The advantage of using the same set of images is that the visual vocabularyis tailored to the search set. The disadvantage of this approach isthat the retrieval system must relearn the visual vocabulary to useon a drastically different set of images. With an independent set,the visual vocabulary is better able to handle the additions of newimages into the search index.indexImages
function createsa search index that maps visual words to their occurrences in theimage collection. When you create the bag of visual words using anindependent or subset collection, include the bag
asan input argument to indexImages
. If you do notcreate an independent bag of visual words, then the function createsthe bag based on the entire imgSet
input collection.You can add and remove images directly to and from the image indexusing the addImages
and removeImages
methods.retrieveImages
functionto search the image set for images which are similar to the queryimage. Use the NumResults
property to controlthe number of results. For example, to return the top 10 similar images,set the ROI
property to use a smaller regionof a query image. A smaller region is useful for isolating a particularobject in an image that you want to search for.evaluateImageRetrieval
functionto evaluate image retrieval by using a query image with a known setof results. If the results are not what you expect, you can modifyor augment image features by the bag of visual words. Examine thetype of the features retrieved. The type of feature used for retrievaldepends on the type of images within the collection. For example,if you are searching an image collection made up of scenes, such asbeaches, cities, or highways, use a global image feature. A globalimage feature, such as a color histogram, captures the key elementsof the entire scene. To find specific objects within the image collections,use local image features extracted around object keypoints instead.