Main Content


(Not recommended) Divide image set into subsets

The partition function of the imageSet object is not recommended. Instead, use the imageDatastore object and its partition function. For more information, see Compatibility Considerations.



[set1,set2,...,setN] = partition(imgSet,groupSizes) partitions the input image set, imgSet, into subsets of size groupSizes.

[set1,set2,...,setN] = partition(imgSet,groupPercentages) partitions the input image set, imgSet, in terms of percentages.

[set1,set2,...,setN] = partition(___,method) additionally specifies a method, 'sequential' or 'randomized'.


collapse all

Create an image set.

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

Divide the set into two groups: one with five images and the other with the remainder of the images from imgSet.

[setA1, setA2] = partition(imgSet,5);

Randomly partition the set into three groups: one with 20% of the images, the second group with 30%, and the third group with 50%.

[setB1, setB2, setB3] = partition(imgSet, [0.2, 0.3],'randomized');

Input Arguments

collapse all

Image set, specified as a scalar imageSet object or an array of imageSet objects.

Group size of images, specified as a positive integer or vector of positive integers. The number of output arguments must be between 1 and length(groupSizes) + 1.

Example: [20 60] returns 20 images in set1, 60 images in set2, and any remaining images in set3.

Group size of images by percentage.

Example: [0.1 0.5] returns 10% of images in set1, 50% in set2, and the remainder in set3.

Image selection method, specified as either method or 'randomized'. When you set method to 'randomized' the images are randomly selected to form the new sets. When you set method to 'sequential' the images are selected sequentially.

Output Arguments

collapse all

Partitioned image sets, returned as an array of imageSet objects.

Compatibility Considerations

expand all

Not recommended starting in R2016b

Introduced in R2014b