imageSet class

Define collection of images

Syntax

imgSet = imageSet(imageLocation)
imgSetVector = imageSet(imgFolder,'recursive')

Construction

imgSet = imageSet(imageLocation) returns an object for storing 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.

Note

You can use the imageDatastore object with greater data management capability instead of imageSet.

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, 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 1. Image file location

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

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

Properties

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 image set.

Data Types: double | single

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

Data Types: cell

Methods

partitionDivide image set into subsets
readRead image at specified index
selectSelect subset of images from image set
Common to All System Objects
release

Allow System object™ property value changes

Examples

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.

imshow(read(imgSet,1));

Identify the path to the image sets.

imgFolder = fullfile(matlabroot, 'toolbox','vision',...
    'visiondata','imageSets');

Recursively scan the entire image set folder.

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

    Description
    ImageLocation
    Count

Display the names of the scanned folders.

{imgSets.Description}
ans = 1x2 cell
    {'books'}    {'cups'}

Display 2nd image from the 'cups' folder.

imshow(read(imgSets(2),2));

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);
Introduced in R2014b