Main Content

shuffle

Shuffle data in augmentedImageDatastore

Description

auimds2 = shuffle(auimds) returns an augmentedImageDatastore object containing a random ordering of the data from augmented image datastore auimds.

example

Examples

collapse all

Load the sample data, which consists of synthetic images of handwritten digits. XTrain is a 28-by-28-by-1-by-5000 array, where:

  • 28 is the height and width of the images.

  • 1 is the number of channels.

  • 5000 is the number of synthetic images of handwritten digits.

load DigitsDataTrain
whos XTrain
  Name         Size                      Bytes  Class     Attributes

  XTrain      28x28x1x5000            31360000  double              

Create an imageDataAugmenter object that specifies preprocessing options for image augmentation, such as resizing, rotation, translation, and reflection. Randomly translate the images up to three pixels horizontally and vertically, and rotate the images with an angle up to 20 degrees.

imageAugmenter = imageDataAugmenter( ...
    RandRotation=[-20,20], ...
    RandXTranslation=[-3 3], ...
    RandYTranslation=[-3 3]);

Create an augmentedImageDatastore using the image data augmented. When you read from the datastore, for example during network training using the trainnet function, the datastore performs image augmentation and resizes the images. The datastore augments the images without saving any images to memory.

imageSize = [64 64 1];
augimds = augmentedImageDatastore(imageSize,XTrain,DataAugmentation=imageAugmenter);
numObservations = augimds.NumObservations;

Shuffle the images to create a new datastore containing the same images in a random order.

augimds = shuffle(augimds);

Read from the datastore and show the first nine images.

minibatch = read(augimds);
imshow(imtile(minibatch.input(1:9)))

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Augmented image datastore, specified as an augmentedImageDatastore object.

Output Arguments

collapse all

Output datastore, returned as an augmentedImageDatastore object containing randomly ordered files from auimds.

Version History

Introduced in R2018a