Search code examples
matlabcomputer-visionmatlab-cvst

Matlab Computer Vision: How to use image in memory for imageSet?


I am currently working on a project at home and hoping to use the Computer Vision toolbox in Matlab to retrieve images from a set that match based on my query image. In fact, the example I'm using from the Matlab documentation here: Image Matching Example

The snag I keep bumping into is that it appears the imageSet class in Matlab only works on files saved to disk. Unfortunately, the work I'm doing has a 4D matrix of an image collection I've created artificially. More specifically, it has the shape (M,N,RGB,I) where

  • M = number of pixels in X-dir
  • N = number of pixels in Y-dir
  • RGB = size of 3, where each channel for RGB is stored as a page
  • I = the image number (up to 10,000, for example)

It seems pretty silly that I have to write everything to files for me to employ the imageSet class object.

So, the question is: Does anyone know a way to create the imageSet object (or similar) without have to write everything to a tmp dir on disk to carry out the analysis, that is, create imageSet from workspace variables?

For the life of me this one had me stumped all weekend. I know I could capitulate and write to files, but somehow that just bothers me.

Any help is greatly appreciated.


Solution

  • You are correct, imageSet only stores file names, and gives you a read method to read a particular image from disk.

    In general, if you already have the images in memory, you can simply store them in a cell array. Or, if your images are all the same size, you can keep them in a single multi-dimensional array.

    However, in this particular case, you are using bagOfFeatures, which currently only takes imageSet. So you will have to save your images to files.