Main Content


(To be removed) Define collection of images

    The imageSet object will be removed in a future release. Instead, manage collections of image data using an imageDatastore object. For more information, see Compatibility Considerations.


    An imageSet object stores information about an image data set or a collection of image data sets. You can use this object to manage your image data. The object contains image descriptions, locations of images, and the number of images in your collection.




    imgSet = imageSet(imageLocation) creates an imageSet object.

    imgSetVector = imageSet(imgFolder,'recursive') returns a vector of image sets found through a recursive search starting from imgFolder. The imgSetVector output is a 1-by-NumFolders vector of imageSet objects, where NumFolders is the number of folders that contain at least one image.

    Input Arguments

    expand all

    Image file location, specified as a character vector or a cell array. The vector must specify the folder name that contains the images. The image files name extensions must be supported by imread. The cell array must contain image locations.

    Example: {'imagePath1','imagePath2', ..., 'imagePathX'}, where each imagePath represents the path to an image.

    Start recursive image search folder, specified as a character vector. The function searches the folder structure recursively, starting from imgFolder.


    expand all

    Information about the image set, specified as a character vector. When you create an image set by recursively searching folders or by specifying a single folder location, the Description property is set to the folder name. When you specify individual image files, the Description property is not set. You can set the property manually.

    Data Types: char

    Number of images in the image set, specified as a positive integer.

    Data Types: double | single

    Image locations, specified as a cell array of character vectors.

    Data Types: cell

    Object Functions

    partition(Not recommended) Divide image set into subsets
    read(Not recommended) Read image at specified index
    select(Not recommended) Select subset of images from image set


    collapse all

    Read the folder of images.

    imgFolder = fullfile(toolboxdir('vision'),'visiondata','stopSignImages');
    imgSet = imageSet(imgFolder);

    Display the first image in the image set collection.


    Identify the path to the image sets.

    imgFolder = fullfile(matlabroot, 'toolbox','vision',...

    Recursively scan the entire image set folder.

    imgSets = imageSet(imgFolder,'recursive')
    imgSets=1×2 imageSet array with properties:

    Display the names of the scanned folders.

    ans = 1x2 cell
        {'books'}    {'cups'}

    Display 2nd image from the 'cups' folder.


    Specify individual images.

    As an alternative to the method below, you can pick the files manually using imgetfile: imgFiles = imgetfile('MultiSelect',true);

    imgFiles = { fullfile(matlabroot,'toolbox','vision','visiondata','stopSignImages','image001.jpg'),...
                 fullfile(matlabroot,'toolbox','vision','visiondata','stopSignImages','image002.jpg') };

    Create image set.

    imgSet   = imageSet(imgFiles);

    Version History

    Introduced in R2014b

    expand all

    R2023b: imageSet will be removed in a future release

    imageSet will be removed in a future release. Use imageDatastore instead, which offers more functionality.