partition

Class: imageSet

Divide image set into subsets

Syntax

[set1,set2,...,setN] = partition(imgSet,groupSizes)
[set1,set2,...,setN] = partition(imgSet,groupPercentages)
[set1,set2,...,setN] = partition(___,method)

Description

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

[set1,set2,...,setN] = partition(imgSet,groupPercentages) returns the partitioned image sets in terms of percentages.

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

Input Arguments

expand all

Image set, specified as an array of imageSet objects.

Group size of images, specified as a scalar. The number of output arguments must be between 1 and length(groupSizes) + 1.

Example 2. Example

If you set groupSizes to [20 60], the method returns 20 images in set1, 60 images in set2, and the remainder of images in set3.

Group size of images by percentage.

Example 3. Example

If you set groupPercentages to [0.1 0.5], the method 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.

Examples

expand 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');